Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat convert strcpy to a bounded copy to avoid compile...
details: https://anonhg.NetBSD.org/src/rev/0486604aef5f
branches: trunk
changeset: 820710:0486604aef5f
user: christos <christos%NetBSD.org@localhost>
date: Fri Jan 13 21:02:05 2017 +0000
description:
convert strcpy to a bounded copy to avoid compiler warnings, although the
reclen test prevents overflow.
diffstat:
sys/compat/linux/common/linux_file64.c | 7 ++++---
sys/compat/linux32/common/linux32_dirent.c | 7 ++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diffs (56 lines):
diff -r 380617d63c35 -r 0486604aef5f sys/compat/linux/common/linux_file64.c
--- a/sys/compat/linux/common/linux_file64.c Fri Jan 13 21:00:59 2017 +0000
+++ b/sys/compat/linux/common/linux_file64.c Fri Jan 13 21:02:05 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_file64.c,v 1.55 2013/12/27 14:17:11 njoly Exp $ */
+/* $NetBSD: linux_file64.c,v 1.56 2017/01/13 21:02:05 christos Exp $ */
/*-
* Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.55 2013/12/27 14:17:11 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.56 2017/01/13 21:02:05 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -354,7 +354,8 @@
idb.d_type = bdp->d_type;
idb.d_off = off;
idb.d_reclen = (u_short)linux_reclen;
- strcpy(idb.d_name, bdp->d_name);
+ memcpy(idb.d_name, bdp->d_name, MIN(sizeof(idb.d_name),
+ bdp.d_namlen);
if ((error = copyout((void *)&idb, outp, linux_reclen)))
goto out;
/* advance past this real entry */
diff -r 380617d63c35 -r 0486604aef5f sys/compat/linux32/common/linux32_dirent.c
--- a/sys/compat/linux32/common/linux32_dirent.c Fri Jan 13 21:00:59 2017 +0000
+++ b/sys/compat/linux32/common/linux32_dirent.c Fri Jan 13 21:02:05 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_dirent.c,v 1.13 2011/10/14 09:23:29 hannken Exp $ */
+/* $NetBSD: linux32_dirent.c,v 1.14 2017/01/13 21:02:05 christos Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.13 2011/10/14 09:23:29 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_dirent.c,v 1.14 2017/01/13 21:02:05 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -215,7 +215,8 @@
idb.d_off = (linux32_off_t)off;
idb.d_reclen = (u_short)linux32_reclen;
}
- strcpy(idb.d_name, bdp->d_name);
+ memcpy(idb.d_name, bdp->d_name, MIN(sizeof(idb.d_name),
+ bdp->d_namlen));
idb.d_name[strlen(idb.d_name) + 1] = bdp->d_type;
if ((error = copyout((void *)&idb, outp, linux32_reclen)))
goto out;
Home |
Main Index |
Thread Index |
Old Index