diff mbox

[1/4] linux-user: fix clock_gettime()

Message ID 1477395977-5367-2-git-send-email-dejan.jovicevic@rt-rk.com
State New
Headers show

Commit Message

Dejan Jovicevic Oct. 25, 2016, 11:46 a.m. UTC
When timespec stucture pointer points outside the accessible
address space (i.e. it's an invalid pointer), the clock_gettime()
syscall should return with -1 and set the errno to EFAULT.
This wasn't the case, since there was no check if the
host_to_target_timespec() failed. This check was added and
now the syscall behaves appropriately in this situation.

Signed-off-by: Dejan Jovicevic <dejan.jovicevic@rt-rk.com>
---
 linux-user/syscall.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 03339ba..e6abfc5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -11247,7 +11247,9 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         struct timespec ts;
         ret = get_errno(clock_gettime(arg1, &ts));
         if (!is_error(ret)) {
-            host_to_target_timespec(arg2, &ts);
+            if (host_to_target_timespec(arg2, &ts)) {
+                goto efault;
+            }
         }
         break;
     }