diff options
author | dchagin <dchagin@FreeBSD.org> | 2016-01-09 17:53:32 +0000 |
---|---|---|
committer | dchagin <dchagin@FreeBSD.org> | 2016-01-09 17:53:32 +0000 |
commit | 5835d4a5eb53fc51fba660a04f87d6fbee2561b1 (patch) | |
tree | b854fdbf9e4fd3065890ad1260088794ce7013b6 /sys/compat/linux | |
parent | b5efd2488f0723cef24e597a690286e3b4c9ec21 (diff) | |
download | FreeBSD-src-5835d4a5eb53fc51fba660a04f87d6fbee2561b1.zip FreeBSD-src-5835d4a5eb53fc51fba660a04f87d6fbee2561b1.tar.gz |
MFC r283491:
Properly check tv_nsec value. The tv_nsec field can also be one
of the special value UTIME_NOW or UTIME_OMIT.
Diffstat (limited to 'sys/compat/linux')
-rw-r--r-- | sys/compat/linux/linux_misc.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 1c626ad..d87d786 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -139,6 +139,9 @@ struct l_pselect6arg { l_size_t ss_len; }; +static int linux_utimensat_nsec_valid(l_long); + + int linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args) { @@ -823,6 +826,17 @@ linux_utimes(struct thread *td, struct linux_utimes_args *args) return (error); } +static int +linux_utimensat_nsec_valid(l_long nsec) +{ + + if (nsec == LINUX_UTIME_OMIT || nsec == LINUX_UTIME_NOW) + return (0); + if (nsec >= 0 && nsec <= 999999999) + return (0); + return (1); +} + int linux_utimensat(struct thread *td, struct linux_utimensat_args *args) { @@ -846,8 +860,8 @@ linux_utimensat(struct thread *td, struct linux_utimensat_args *args) if (error != 0) return (error); - if (l_times[0].tv_nsec > 999999999 || - l_times[1].tv_nsec > 999999999) + if (linux_utimensat_nsec_valid(l_times[0].tv_nsec) != 0 || + linux_utimensat_nsec_valid(l_times[1].tv_nsec) != 0) return (EINVAL); times[0].tv_sec = l_times[0].tv_sec; |