svn commit: r279214 - user/dchagin/lemul/sys/compat/linux

Dmitry Chagin dchagin at FreeBSD.org
Mon Feb 23 19:36:32 UTC 2015


Author: dchagin
Date: Mon Feb 23 19:36:31 2015
New Revision: 279214
URL: https://svnweb.freebsd.org/changeset/base/279214

Log:
  Properly check tv_nsec value. The tv_nsec field can also be one
  of the special value UTIME_NOW or UTIME_OMIT.

Modified:
  user/dchagin/lemul/sys/compat/linux/linux_misc.c

Modified: user/dchagin/lemul/sys/compat/linux/linux_misc.c
==============================================================================
--- user/dchagin/lemul/sys/compat/linux/linux_misc.c	Mon Feb 23 18:57:09 2015	(r279213)
+++ user/dchagin/lemul/sys/compat/linux/linux_misc.c	Mon Feb 23 19:36:31 2015	(r279214)
@@ -138,6 +138,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)
 {
@@ -824,6 +827,17 @@ linux_utimes(struct thread *td, struct l
 	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)
 {
@@ -847,8 +861,8 @@ linux_utimensat(struct thread *td, struc
 		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;


More information about the svn-src-user mailing list