Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/common convert strcpy to a bounded copy to avoid ...



details:   https://anonhg.NetBSD.org/src/rev/8173e6ab6b50
branches:  trunk
changeset: 820708:8173e6ab6b50
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jan 13 20:58:59 2017 +0000

description:
convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.

diffstat:

 sys/compat/common/vfs_syscalls_12.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 106ba1674e5d -r 8173e6ab6b50 sys/compat/common/vfs_syscalls_12.c
--- a/sys/compat/common/vfs_syscalls_12.c       Fri Jan 13 20:46:15 2017 +0000
+++ b/sys/compat/common/vfs_syscalls_12.c       Fri Jan 13 20:58:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls_12.c,v 1.31 2014/09/05 09:21:54 matt Exp $        */
+/*     $NetBSD: vfs_syscalls_12.c,v 1.32 2017/01/13 20:58:59 christos Exp $    */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_12.c,v 1.31 2014/09/05 09:21:54 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_12.c,v 1.32 2017/01/13 20:58:59 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -196,7 +196,8 @@
                idb.d_reclen = (uint16_t)old_reclen;
                idb.d_type = (uint8_t)bdp->d_type;
                idb.d_namlen = (uint8_t)bdp->d_namlen;
-               strcpy(idb.d_name, bdp->d_name);
+               memcpy(idb.d_name, bdp->d_name, MIN(sizeof(idb.d_name),
+                   idb.d_namlen));
                if ((error = copyout(&idb, outp, old_reclen)))
                        goto out;
                /* advance past this real entry */



Home | Main Index | Thread Index | Old Index