Source-Changes-HG archive

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

[src/trunk]: src/sys/compat use strlcpy



details:   https://anonhg.NetBSD.org/src/rev/8b9e8494ba6a
branches:  trunk
changeset: 547281:8b9e8494ba6a
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri May 16 14:36:30 2003 +0000

description:
use strlcpy
[compat/svr4_32 should have bound check for SVR4_32_AUX_ARGSIZ]

diffstat:

 sys/compat/ibcs2/ibcs2_misc.c     |  6 +++---
 sys/compat/irix/irix_dirent.c     |  8 ++++----
 sys/compat/irix/irix_stat.c       |  8 ++++----
 sys/compat/mach/mach_bootstrap.c  |  9 +++++----
 sys/compat/sunos/sunos_misc.c     |  6 +++---
 sys/compat/sunos32/sunos32_misc.c |  6 +++---
 sys/compat/svr4/svr4_misc.c       |  8 ++++----
 sys/compat/svr4/svr4_stat.c       |  8 ++++----
 sys/compat/svr4_32/svr4_32_misc.c |  8 ++++----
 sys/compat/svr4_32/svr4_32_stat.c |  8 ++++----
 10 files changed, 38 insertions(+), 37 deletions(-)

diffs (truncated from 334 to 300 lines):

diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/ibcs2/ibcs2_misc.c
--- a/sys/compat/ibcs2/ibcs2_misc.c     Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/ibcs2/ibcs2_misc.c     Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ibcs2_misc.c,v 1.63 2003/01/29 07:00:35 atatat Exp $   */
+/*     $NetBSD: ibcs2_misc.c,v 1.64 2003/05/16 14:36:30 itojun Exp $   */
 
 /*
  * Copyright (c) 1994, 1995, 1998 Scott Bartram
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.63 2003/01/29 07:00:35 atatat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_misc.c,v 1.64 2003/05/16 14:36:30 itojun Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -451,7 +451,7 @@
                idb.d_ino = (ibcs2_ino_t)bdp->d_fileno;
                idb.d_off = (ibcs2_off_t)off;
                idb.d_reclen = (u_short)ibcs2_reclen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                error = copyout(&idb, outp, ibcs2_reclen);
                if (error)
                        goto out;
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/irix/irix_dirent.c
--- a/sys/compat/irix/irix_dirent.c     Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/irix/irix_dirent.c     Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_dirent.c,v 1.8 2003/01/22 12:58:22 rafal Exp $ */
+/*     $NetBSD: irix_dirent.c,v 1.9 2003/05/16 14:36:32 itojun Exp $ */
 
 /*-
  * Copyright (c) 1994, 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.8 2003/01/22 12:58:22 rafal Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_dirent.c,v 1.9 2003/05/16 14:36:32 itojun Exp $");
 
 #include <sys/types.h>
 #include <sys/signal.h>
@@ -171,7 +171,7 @@
                idb.d_ino = (irix_ino_t)bdp->d_fileno;
                idb.d_off = (irix_off_t)off;
                idb.d_reclen = (u_short)svr4_reclen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                if ((error = copyout((caddr_t)&idb, outp, svr4_reclen)))
                        goto out;
                /* advance past this real entry */
@@ -324,7 +324,7 @@
                idb.d_ino = (irix_ino64_t)bdp->d_fileno;
                idb.d_off = (irix_off64_t)off;
                idb.d_reclen = (u_short)svr4_reclen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                if ((error = copyout((caddr_t)&idb, outp, svr4_reclen)))
                        goto out;
                /* advance past this real entry */
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/irix/irix_stat.c
--- a/sys/compat/irix/irix_stat.c       Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/irix/irix_stat.c       Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_stat.c,v 1.7 2003/01/22 12:58:23 rafal Exp $ */
+/*     $NetBSD: irix_stat.c,v 1.8 2003/05/16 14:36:32 itojun Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_stat.c,v 1.7 2003/01/22 12:58:23 rafal Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_stat.c,v 1.8 2003/05/16 14:36:32 itojun Exp $");
 
 #include <sys/errno.h>
 #include <sys/types.h>
@@ -90,7 +90,7 @@
        isp->ist_size = bsp->st_size;
        isp->ist_blocks = bsp->st_blocks;
        isp->ist_blksize = bsp->st_blksize;
-       strcpy(isp->ist_fstype, "unknown");
+       strlcpy(isp->ist_fstype, "unknown", sizeof(isp->ist_fstype));
 
        return;
 }
@@ -122,7 +122,7 @@
        isp->ist_size = bsp->st_size;
        isp->ist_blocks = bsp->st_blocks;
        isp->ist_blksize = bsp->st_blksize;
-       strcpy(isp->ist_fstype, "unknown");
+       strlcpy(isp->ist_fstype, "unknown", sizeof(isp->ist_fstype));
 
        return;
 }
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/mach/mach_bootstrap.c
--- a/sys/compat/mach/mach_bootstrap.c  Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/mach/mach_bootstrap.c  Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mach_bootstrap.c,v 1.5 2003/01/21 04:06:07 matt Exp $ */
+/*     $NetBSD: mach_bootstrap.c,v 1.6 2003/05/16 14:36:33 itojun Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mach_bootstrap.c,v 1.5 2003/01/21 04:06:07 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mach_bootstrap.c,v 1.6 2003/05/16 14:36:33 itojun Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -59,7 +59,7 @@
        mach_bootstrap_look_up_reply_t *rep = args->rmsg;
        struct lwp *l = args->l;
        size_t *msglen = args->rsize;
-       const char service_name[] = "lookup\21"; /* XXX Why */
+       const char service_name[] = "lookup\021"; /* XXX Why */
        int service_name_len;
        struct mach_right *mr;
 
@@ -79,7 +79,8 @@
        rep->rep_msgh.msgh_id = req->req_msgh.msgh_id + 100;
        rep->rep_count = 1; /* XXX Why? */
        rep->rep_bootstrap_port = mr->mr_name;
-       strcpy((char *)&rep->rep_service_name, service_name); 
+       strlcpy((char *)&rep->rep_service_name, service_name,
+           sizeof(rep->rep_service_name)); 
        /* XXX This is the trailer. We should find something better */
        rep->rep_service_name[service_name_len + 7] = 8;
 
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/sunos/sunos_misc.c
--- a/sys/compat/sunos/sunos_misc.c     Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/sunos/sunos_misc.c     Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sunos_misc.c,v 1.120 2003/02/23 14:37:32 pk Exp $      */
+/*     $NetBSD: sunos_misc.c,v 1.121 2003/05/16 14:36:33 itojun Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.120 2003/02/23 14:37:32 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.121 2003/05/16 14:36:33 itojun Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfsserver.h"
@@ -577,7 +577,7 @@
                idb.d_off = off;
                idb.d_reclen = sunos_reclen;
                idb.d_namlen = bdp->d_namlen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                if ((error = copyout((caddr_t)&idb, outp, sunos_reclen)) != 0)
                        goto out;
                /* advance past this real entry */
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/sunos32/sunos32_misc.c
--- a/sys/compat/sunos32/sunos32_misc.c Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/sunos32/sunos32_misc.c Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sunos32_misc.c,v 1.17 2003/01/29 07:00:38 atatat Exp $ */
+/*     $NetBSD: sunos32_misc.c,v 1.18 2003/05/16 14:36:34 itojun Exp $ */
 /* from :NetBSD: sunos_misc.c,v 1.107 2000/12/01 19:25:10 jdolecek Exp */
 
 /*
@@ -83,7 +83,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.17 2003/01/29 07:00:38 atatat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunos32_misc.c,v 1.18 2003/05/16 14:36:34 itojun Exp $");
 
 #define COMPAT_SUNOS 1
 
@@ -795,7 +795,7 @@
                idb.d_off = off;
                idb.d_reclen = sunos_reclen;
                idb.d_namlen = bdp->d_namlen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                if ((error = copyout((caddr_t)&idb, outp, sunos_reclen)) != 0)
                        goto out;
                /* advance past this real entry */
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/svr4/svr4_misc.c
--- a/sys/compat/svr4/svr4_misc.c       Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/svr4/svr4_misc.c       Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_misc.c,v 1.103 2003/04/01 01:55:09 thorpej Exp $   */
+/*     $NetBSD: svr4_misc.c,v 1.104 2003/05/16 14:36:35 itojun Exp $    */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.103 2003/04/01 01:55:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_misc.c,v 1.104 2003/05/16 14:36:35 itojun Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -345,7 +345,7 @@
                idb.d_ino = (svr4_ino64_t)bdp->d_fileno;
                idb.d_off = (svr4_off64_t)off;
                idb.d_reclen = (u_short)svr4_reclen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                if ((error = copyout((caddr_t)&idb, outp, svr4_reclen)))
                        goto out;
                /* advance past this real entry */
@@ -469,7 +469,7 @@
                idb.d_ino = (svr4_ino_t)bdp->d_fileno;
                idb.d_off = (svr4_off_t)off;
                idb.d_reclen = (u_short)svr4_reclen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                if ((error = copyout((caddr_t)&idb, outp, svr4_reclen)))
                        goto out;
                /* advance past this real entry */
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/svr4/svr4_stat.c
--- a/sys/compat/svr4/svr4_stat.c       Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/svr4/svr4_stat.c       Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_stat.c,v 1.46 2003/01/18 08:44:27 thorpej Exp $    */
+/*     $NetBSD: svr4_stat.c,v 1.47 2003/05/16 14:36:35 itojun Exp $     */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_stat.c,v 1.46 2003/01/18 08:44:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_stat.c,v 1.47 2003/05/16 14:36:35 itojun Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -140,7 +140,7 @@
        st4->st_ctim.tv_nsec = st->st_ctimespec.tv_nsec;
        st4->st_blksize = st->st_blksize;
        st4->st_blocks = st->st_blocks;
-       strcpy(st4->st_fstype, "unknown");
+       strlcpy(st4->st_fstype, "unknown", sizeof(st4->st_fstype));
 }
 
 
@@ -166,7 +166,7 @@
        st4->st_ctim.tv_nsec = st->st_ctimespec.tv_nsec;
        st4->st_blksize = st->st_blksize;
        st4->st_blocks = st->st_blocks;
-       strcpy(st4->st_fstype, "unknown");
+       strlcpy(st4->st_fstype, "unknown", sizeof(st4->st_fstype));
 }
 
 
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/svr4_32/svr4_32_misc.c
--- a/sys/compat/svr4_32/svr4_32_misc.c Fri May 16 14:25:02 2003 +0000
+++ b/sys/compat/svr4_32/svr4_32_misc.c Fri May 16 14:36:30 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: svr4_32_misc.c,v 1.18 2003/04/01 01:55:38 thorpej Exp $         */
+/*     $NetBSD: svr4_32_misc.c,v 1.19 2003/05/16 14:36:35 itojun Exp $  */
 
 /*-
  * Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.18 2003/04/01 01:55:38 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_32_misc.c,v 1.19 2003/05/16 14:36:35 itojun Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -347,7 +347,7 @@
                idb.d_ino = (svr4_32_ino64_t)bdp->d_fileno;
                idb.d_off = (svr4_32_off64_t)off;
                idb.d_reclen = (u_short)svr4_32_reclen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                if ((error = copyout((caddr_t)&idb, outp, svr4_32_reclen)))
                        goto out;
                /* advance past this real entry */
@@ -471,7 +471,7 @@
                idb.d_ino = (svr4_32_ino_t)bdp->d_fileno;
                idb.d_off = (svr4_32_off_t)off;
                idb.d_reclen = (u_short)svr4_reclen;
-               strcpy(idb.d_name, bdp->d_name);
+               strlcpy(idb.d_name, bdp->d_name, sizeof(idb.d_name));
                if ((error = copyout((caddr_t)&idb, outp, svr4_reclen)))
                        goto out;
                /* advance past this real entry */
diff -r 3993ce6fefcd -r 8b9e8494ba6a sys/compat/svr4_32/svr4_32_stat.c
--- a/sys/compat/svr4_32/svr4_32_stat.c Fri May 16 14:25:02 2003 +0000



Home | Main Index | Thread Index | Old Index