Hi guys,

I was playing around with tame() today, and have a couple of minor
suggestions:


- Return EINVAL instead of ENAMETOOLONG if the request argument string
is too long. ENAMETOOLONG translates to "File name too long", which I
think is misleading. Maybe E2BIG would be an alternative, but EINVAL
feels better to me since it is clearly an invalid argument being passed.
ENAMETOOLONG is still appropriate for the paths argument of course.

- Add same [EINVAL] condition to the ERRORS section in tame.2.

- While there, elaborate a bit on [EFAULT] since there are more error
conditions that can generate that.


Regards,

/Benny



Index: lib/libc/sys/tame.2
===================================================================
RCS file: /cvs/src/lib/libc/sys/tame.2,v
retrieving revision 1.31
diff -u -p -r1.31 tame.2
--- lib/libc/sys/tame.2 4 Oct 2015 20:47:16 -0000       1.31
+++ lib/libc/sys/tame.2 5 Oct 2015 21:06:06 -0000
@@ -424,6 +424,8 @@ will fail if:
 .Bl -tag -width Er
 .It Bq Er EFAULT
 .Fa paths
+or one of its elements, or
+.Fa request
 points outside the process's allocated address space.
 .It Bq Er ENAMETOOLONG
 An element of
@@ -435,6 +437,9 @@ to it would exceed
 bytes.
 .It Bq Er EPERM
 This process is attempting to increase permissions.
+.It Bq Er EINVAL
+.Ar request
+is malformed or too long.
 .It Bq Er E2BIG
 The
 .Ar paths
Index: sys/kern/kern_tame.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_tame.c,v
retrieving revision 1.57
diff -u -p -r1.57 kern_tame.c
--- sys/kern/kern_tame.c        4 Oct 2015 17:55:21 -0000       1.57
+++ sys/kern/kern_tame.c        5 Oct 2015 21:06:13 -0000
@@ -255,7 +255,7 @@ sys_tame(struct proc *p, void *v, regist
                    &rbuflen);
                if (error) {
                        free(rbuf, M_TEMP, MAXPATHLEN);
-                       return (error);
+                       return ((error == ENAMETOOLONG) ? EINVAL : error);
                }
 #ifdef KTRACE
                if (KTRPOINT(p, KTR_STRUCT))

Reply via email to