Module Name:    src
Committed By:   christos
Date:           Fri Jan 13 21:02:05 UTC 2017

Modified Files:
        src/sys/compat/linux/common: linux_file64.c
        src/sys/compat/linux32/common: linux32_dirent.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/compat/linux/common/linux_file64.c
cvs rdiff -u -r1.13 -r1.14 src/sys/compat/linux32/common/linux32_dirent.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/linux/common/linux_file64.c
diff -u src/sys/compat/linux/common/linux_file64.c:1.55 src/sys/compat/linux/common/linux_file64.c:1.56
--- src/sys/compat/linux/common/linux_file64.c:1.55	Fri Dec 27 09:17:11 2013
+++ src/sys/compat/linux/common/linux_file64.c	Fri Jan 13 16:02:05 2017
@@ -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 @@ again:
 		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 */

Index: src/sys/compat/linux32/common/linux32_dirent.c
diff -u src/sys/compat/linux32/common/linux32_dirent.c:1.13 src/sys/compat/linux32/common/linux32_dirent.c:1.14
--- src/sys/compat/linux32/common/linux32_dirent.c:1.13	Fri Oct 14 05:23:29 2011
+++ src/sys/compat/linux32/common/linux32_dirent.c	Fri Jan 13 16:02:05 2017
@@ -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 @@ again:
 			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;

Reply via email to