Subject: getdirentries(2): argument doesn't match
To: None <tech-kern@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-kern
Date: 10/03/2002 13:53:26
it seems that signedness of getdirentries(2) does not meet up with
document. does it make sense? found by checking openbsd commit log.
itojun
Index: common/vfs_syscalls_12.c
===================================================================
RCS file: /cvsroot/syssrc/sys/compat/common/vfs_syscalls_12.c,v
retrieving revision 1.10
diff -u -r1.10 vfs_syscalls_12.c
--- common/vfs_syscalls_12.c 2001/11/13 02:08:04 1.10
+++ common/vfs_syscalls_12.c 2002/10/03 04:52:29
@@ -103,12 +103,15 @@
struct compat_12_sys_getdirentries_args /* {
syscallarg(int) fd;
syscallarg(char *) buf;
- syscallarg(u_int) count;
+ syscallarg(int) count;
syscallarg(long *) basep;
} */ *uap = v;
struct file *fp;
int error, done;
long loff;
+
+ if (SCARG(uap, count) < 0)
+ return EINVAL;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
Index: common/vfs_syscalls_43.c
===================================================================
RCS file: /cvsroot/syssrc/sys/compat/common/vfs_syscalls_43.c,v
retrieving revision 1.20
diff -u -r1.20 vfs_syscalls_43.c
--- common/vfs_syscalls_43.c 2001/11/13 02:08:05 1.20
+++ common/vfs_syscalls_43.c 2002/10/03 04:52:29
@@ -377,7 +377,7 @@
struct compat_43_sys_getdirentries_args /* {
syscallarg(int) fd;
syscallarg(char *) buf;
- syscallarg(u_int) count;
+ syscallarg(int) count;
syscallarg(long *) basep;
} */ *uap = v;
struct vnode *vp;
@@ -388,6 +388,9 @@
caddr_t dirbuf;
int error, eofflag, readcnt;
long loff;
+
+ if (SCARG(uap, count) < 0)
+ return EINVAL;
/* getvnode() will use the descriptor for us */
if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
Index: netbsd32/netbsd32_compat_12.c
===================================================================
RCS file: /cvsroot/syssrc/sys/compat/netbsd32/netbsd32_compat_12.c,v
retrieving revision 1.14
diff -u -r1.14 netbsd32_compat_12.c
--- netbsd32/netbsd32_compat_12.c 2002/03/16 20:43:54 1.14
+++ netbsd32/netbsd32_compat_12.c 2002/10/03 04:52:30
@@ -231,7 +231,7 @@
struct compat_12_netbsd32_getdirentries_args /* {
syscallarg(int) fd;
syscallarg(netbsd32_charp) buf;
- syscallarg(u_int) count;
+ syscallarg(int) count;
syscallarg(netbsd32_longp) basep;
} */ *uap = v;
struct compat_12_sys_getdirentries_args ua;