Module Name: src Committed By: christos Date: Sun Dec 3 15:23:30 UTC 2017
Modified Files: src/sys/compat/common: vfs_syscalls_12.c vfs_syscalls_43.c Log Message: Make code look the same, in particular zero out the rest of the directory record. XXX: pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/compat/common/vfs_syscalls_12.c cvs rdiff -u -r1.61 -r1.62 src/sys/compat/common/vfs_syscalls_43.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/compat/common/vfs_syscalls_12.c diff -u src/sys/compat/common/vfs_syscalls_12.c:1.34 src/sys/compat/common/vfs_syscalls_12.c:1.35 --- src/sys/compat/common/vfs_syscalls_12.c:1.34 Fri Jul 28 11:34:06 2017 +++ src/sys/compat/common/vfs_syscalls_12.c Sun Dec 3 10:23:30 2017 @@ -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 @@ again: 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 @@ again: 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 */ Index: src/sys/compat/common/vfs_syscalls_43.c diff -u src/sys/compat/common/vfs_syscalls_43.c:1.61 src/sys/compat/common/vfs_syscalls_43.c:1.62 --- src/sys/compat/common/vfs_syscalls_43.c:1.61 Sat Jul 29 00:02:49 2017 +++ src/sys/compat/common/vfs_syscalls_43.c Sun Dec 3 10:23:30 2017 @@ -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 @@ again: 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 @@ again: */ 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 */