While TZ normally is NULL, and we normally write back 0's, we still should write back rather than read it for gettimeofday.
Signed-off-by: Warner Losh <[email protected]> --- bsd-user/freebsd/os-time.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bsd-user/freebsd/os-time.h b/bsd-user/freebsd/os-time.h index ed075b7df4..29436997ce 100644 --- a/bsd-user/freebsd/os-time.h +++ b/bsd-user/freebsd/os-time.h @@ -124,19 +124,19 @@ static inline abi_long do_freebsd_gettimeofday(abi_ulong arg1, abi_ulong arg2) struct timeval tv; struct timezone tz, *target_tz; /* XXX */ - if (arg2 != 0) { - if (!lock_user_struct(VERIFY_READ, target_tz, arg2, 0)) { - return -TARGET_EFAULT; - } - __get_user(tz.tz_minuteswest, &target_tz->tz_minuteswest); - __get_user(tz.tz_dsttime, &target_tz->tz_dsttime); - unlock_user_struct(target_tz, arg2, 1); - } ret = get_errno(gettimeofday(&tv, arg2 != 0 ? &tz : NULL)); if (!is_error(ret)) { if (h2t_freebsd_timeval(&tv, arg1)) { return -TARGET_EFAULT; } + if (arg2 != 0) { + if (!lock_user_struct(VERIFY_WRITE, target_tz, arg2, 0)) { + return -TARGET_EFAULT; + } + __put_user(tz.tz_minuteswest, &target_tz->tz_minuteswest); + __put_user(tz.tz_dsttime, &target_tz->tz_dsttime); + unlock_user_struct(target_tz, arg2, 1); + } } return ret; -- 2.52.0
