Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Use strlcpy in a few places to guarnatee 0-...



details:   https://anonhg.NetBSD.org/src/rev/bf33f01b76ae
branches:  trunk
changeset: 744966:bf33f01b76ae
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Feb 19 18:08:03 2020 +0000

description:
Use strlcpy in a few places to guarnatee 0-terminated strings

diffstat:

 usr.sbin/sysinst/disklabel.c |  4 ++--
 usr.sbin/sysinst/disks.c     |  4 ++--
 usr.sbin/sysinst/main.c      |  4 ++--
 usr.sbin/sysinst/target.c    |  8 ++++----
 4 files changed, 10 insertions(+), 10 deletions(-)

diffs (83 lines):

diff -r e0697b31479a -r bf33f01b76ae usr.sbin/sysinst/disklabel.c
--- a/usr.sbin/sysinst/disklabel.c      Wed Feb 19 17:13:00 2020 +0000
+++ b/usr.sbin/sysinst/disklabel.c      Wed Feb 19 18:08:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disklabel.c,v 1.35 2020/02/06 11:46:35 martin Exp $    */
+/*     $NetBSD: disklabel.c,v 1.36 2020/02/19 18:08:03 martin Exp $    */
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -934,7 +934,7 @@
        struct disklabel_disk_partitions *parts =
            (struct disklabel_disk_partitions*)arg;
 
-       strncpy(parts->l.d_packname, pack, sizeof(parts->l.d_packname));
+       strlcpy(parts->l.d_packname, pack, sizeof(parts->l.d_packname));
        return true;
 }
 
diff -r e0697b31479a -r bf33f01b76ae usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Wed Feb 19 17:13:00 2020 +0000
+++ b/usr.sbin/sysinst/disks.c  Wed Feb 19 18:08:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.65 2020/02/06 19:08:38 martin Exp $ */
+/*     $NetBSD: disks.c,v 1.66 2020/02/19 18:08:03 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1347,7 +1347,7 @@
                        break;
                case FS_SWAP:
                        if (swap_dev[0] == 0) {
-                               strncpy(swap_dev, dev, sizeof swap_dev);
+                               strlcpy(swap_dev, dev, sizeof swap_dev);
                                dump_dev = ",dp";
                        } else {
                                dump_dev = "";
diff -r e0697b31479a -r bf33f01b76ae usr.sbin/sysinst/main.c
--- a/usr.sbin/sysinst/main.c   Wed Feb 19 17:13:00 2020 +0000
+++ b/usr.sbin/sysinst/main.c   Wed Feb 19 18:08:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.20 2020/01/16 16:47:19 martin Exp $ */
+/*     $NetBSD: main.c,v 1.21 2020/02/19 18:08:03 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -193,7 +193,7 @@
                        break;
                case 'r':
                        /* Release name other than compiled in release. */
-                       strncpy(rel, optarg, sizeof rel);
+                       strlcpy(rel, optarg, sizeof rel);
                        break;
                case 'f':
                        /* Definition file to read. */
diff -r e0697b31479a -r bf33f01b76ae usr.sbin/sysinst/target.c
--- a/usr.sbin/sysinst/target.c Wed Feb 19 17:13:00 2020 +0000
+++ b/usr.sbin/sysinst/target.c Wed Feb 19 18:08:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: target.c,v 1.12 2020/02/06 15:08:04 martin Exp $       */
+/*     $NetBSD: target.c,v 1.13 2020/02/19 18:08:03 martin Exp $       */
 
 /*
  * Copyright 1997 Jonathan Stone
@@ -71,7 +71,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: target.c,v 1.12 2020/02/06 15:08:04 martin Exp $");
+__RCSID("$NetBSD: target.c,v 1.13 2020/02/19 18:08:03 martin Exp $");
 #endif
 
 /*
@@ -436,8 +436,8 @@
        char realfrom[STRSIZE];
        char realto[STRSIZE];
 
-       strncpy(realfrom, target_expand(frompath), STRSIZE);
-       strncpy(realto, target_expand(topath), STRSIZE);
+       strlcpy(realfrom, target_expand(frompath), sizeof realfrom);
+       strlcpy(realto, target_expand(topath), sizeof realto);
 
        if (access(realfrom, R_OK) == -1 && optional)
                return 0;



Home | Main Index | Thread Index | Old Index