Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat/common Make code look the same, in particular zer...



details:   https://anonhg.NetBSD.org/src/rev/2b80be287868
branches:  trunk
changeset: 828225:2b80be287868
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Dec 03 15:23:30 2017 +0000

description:
Make code look the same, in particular zero out the rest of the directory
record.
XXX: pullup-8

diffstat:

 sys/compat/common/vfs_syscalls_12.c |  14 +++++++++-----
 sys/compat/common/vfs_syscalls_43.c |  15 ++++++++++-----
 2 files changed, 19 insertions(+), 10 deletions(-)

diffs (85 lines):

diff -r 7ae940dec7f4 -r 2b80be287868 sys/compat/common/vfs_syscalls_12.c
--- a/sys/compat/common/vfs_syscalls_12.c       Sun Dec 03 14:35:07 2017 +0000
+++ b/sys/compat/common/vfs_syscalls_12.c       Sun Dec 03 15:23:30 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_12.c,v 1.34 2017/07/28 15:34:06 riastradh Exp $   */
+/*     $NetBSD: vfs_syscalls_12.c,v 1.35 2017/12/03 15:23:30 christos Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_12.c,v 1.34 2017/07/28 15:34:06 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_12.c,v 1.35 2017/12/03 15:23:30 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -183,6 +183,10 @@
                                off += reclen;
                        continue;
                }
+               if (bdp->d_namlen >= sizeof(idb.d_name))
+                       idb.d_namlen = sizeof(idb.d_name) - 1;
+               else
+                       idb.d_namlen = bdp->d_namlen;
                old_reclen = _DIRENT_RECLEN(&idb, bdp->d_namlen);
                if (reclen > len || resid < old_reclen) {
                        /* entry too big for buffer, so just stop */
@@ -197,9 +201,9 @@
                idb.d_fileno = (uint32_t)bdp->d_fileno;
                idb.d_reclen = (uint16_t)old_reclen;
                idb.d_type = (uint8_t)bdp->d_type;
-               idb.d_namlen = (uint8_t)bdp->d_namlen;
-               memcpy(idb.d_name, bdp->d_name, MIN(sizeof(idb.d_name),
-                   bdp->d_namlen));
+               (void)memcpy(idb.d_name, bdp->d_name, idb.d_namlen);
+               memset(idb.d_name + idb.d_namlen, 0,
+                   idb.d_reclen - _DIRENT_NAMEOFF(&idb) - idb.d_namlen);
                if ((error = copyout(&idb, outp, old_reclen)))
                        goto out;
                /* advance past this real entry */
diff -r 7ae940dec7f4 -r 2b80be287868 sys/compat/common/vfs_syscalls_43.c
--- a/sys/compat/common/vfs_syscalls_43.c       Sun Dec 03 14:35:07 2017 +0000
+++ b/sys/compat/common/vfs_syscalls_43.c       Sun Dec 03 15:23:30 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_43.c,v 1.61 2017/07/29 04:02:49 riastradh Exp $   */
+/*     $NetBSD: vfs_syscalls_43.c,v 1.62 2017/12/03 15:23:30 christos Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.61 2017/07/29 04:02:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_43.c,v 1.62 2017/12/03 15:23:30 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -463,6 +463,10 @@
                                off += reclen;
                        continue;
                }
+               if (bdp->d_namlen >= sizeof(idb.d_name))
+                       idb.d_namlen = sizeof(idb.d_name) - 1;
+               else
+                       idb.d_namlen = bdp->d_namlen;
                old_reclen = _DIRENT_RECLEN(&idb, bdp->d_namlen);
                if (reclen > len || resid < old_reclen) {
                        /* entry too big for buffer, so just stop */
@@ -476,9 +480,10 @@
                 */
                idb.d_fileno = (uint32_t)bdp->d_fileno;
                idb.d_reclen = (uint16_t)old_reclen;
-               idb.d_namlen = (uint16_t)bdp->d_namlen;
-               memcpy(idb.d_name, bdp->d_name, MIN(sizeof(idb.d_name),
-                   idb.d_namlen));
+               idb.d_fileno = (uint32_t)bdp->d_fileno;
+               (void)memcpy(idb.d_name, bdp->d_name, idb.d_namlen);
+               memset(idb.d_name + idb.d_namlen, 0,
+                   idb.d_reclen - _DIRENT_NAMEOFF(&idb) - idb.d_namlen);
                if ((error = copyout(&idb, outp, old_reclen)))
                        goto out;
                /* advance past this real entry */



Home | Main Index | Thread Index | Old Index