Skip to content

Commit

Permalink
syscall: check inotify() and eventfd() return value
Browse files Browse the repository at this point in the history
linux-user/syscall.c:555:25: warning: Out of bound memory access (accessed memory precedes memory block)
    target_fd_trans[fd] = trans;
    ~~~~~~~~~~~~~~~~~~~~^~~~~~~

Reported-by: Clang Static Analyzer
Suggested-by: Laurent Vivier <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Laurent Vivier <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
philmd authored and Michael Tokarev committed Jul 31, 2017
1 parent 6860710 commit b929f7e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions linux-user/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -11742,15 +11742,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#if defined(TARGET_NR_inotify_init) && defined(__NR_inotify_init)
case TARGET_NR_inotify_init:
ret = get_errno(sys_inotify_init());
fd_trans_register(ret, &target_inotify_trans);
if (ret >= 0) {
fd_trans_register(ret, &target_inotify_trans);
}
break;
#endif
#ifdef CONFIG_INOTIFY1
#if defined(TARGET_NR_inotify_init1) && defined(__NR_inotify_init1)
case TARGET_NR_inotify_init1:
ret = get_errno(sys_inotify_init1(target_to_host_bitmask(arg1,
fcntl_flags_tbl)));
fd_trans_register(ret, &target_inotify_trans);
if (ret >= 0) {
fd_trans_register(ret, &target_inotify_trans);
}
break;
#endif
#endif
Expand Down Expand Up @@ -11916,7 +11920,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#if defined(TARGET_NR_eventfd)
case TARGET_NR_eventfd:
ret = get_errno(eventfd(arg1, 0));
fd_trans_register(ret, &target_eventfd_trans);
if (ret >= 0) {
fd_trans_register(ret, &target_eventfd_trans);
}
break;
#endif
#if defined(TARGET_NR_eventfd2)
Expand All @@ -11930,7 +11936,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
host_flags |= O_CLOEXEC;
}
ret = get_errno(eventfd(arg1, host_flags));
fd_trans_register(ret, &target_eventfd_trans);
if (ret >= 0) {
fd_trans_register(ret, &target_eventfd_trans);
}
break;
}
#endif
Expand Down

0 comments on commit b929f7e

Please sign in to comment.