Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/stat Use strlcpy, not strncpy, when the desired sema...



details:   https://anonhg.NetBSD.org/src/rev/df2d2179b78f
branches:  trunk
changeset: 759750:df2d2179b78f
user:      dholland <dholland%NetBSD.org@localhost>
date:      Thu Dec 16 05:30:16 2010 +0000

description:
Use strlcpy, not strncpy, when the desired semantics are strlcpy's
rather than strncpy's.

diffstat:

 usr.bin/stat/stat.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (64 lines):

diff -r 149cda4245f3 -r df2d2179b78f usr.bin/stat/stat.c
--- a/usr.bin/stat/stat.c       Thu Dec 16 02:01:37 2010 +0000
+++ b/usr.bin/stat/stat.c       Thu Dec 16 05:30:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stat.c,v 1.30 2010/11/25 04:33:30 dholland Exp $ */
+/*     $NetBSD: stat.c,v 1.31 2010/12/16 05:30:16 dholland Exp $ */
 
 /*
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: stat.c,v 1.30 2010/11/25 04:33:30 dholland Exp $");
+__RCSID("$NetBSD: stat.c,v 1.31 2010/12/16 05:30:16 dholland Exp $");
 #endif
 
 #if ! HAVE_NBTOOL_CONFIG_H
@@ -788,7 +788,7 @@
                small = 0;
                data = 0;
                if (file == NULL) {
-                       (void)strncpy(path, "(stdin)", sizeof(path));
+                       (void)strlcpy(path, "(stdin)", sizeof(path));
                        sdata = path;
                } else {
                        snprintf(path, sizeof(path), " -> ");
@@ -881,15 +881,15 @@
                small = 0;
                data = 0;
                if (file == NULL) {
-                       (void)strncpy(path, "(stdin)", sizeof(path));
+                       (void)strlcpy(path, "(stdin)", sizeof(path));
                        if (hilo == HIGH_PIECE || hilo == LOW_PIECE)
                                hilo = 0;
                }
                else if (hilo == 0)
-                       (void)strncpy(path, file, sizeof(path));
+                       (void)strlcpy(path, file, sizeof(path));
                else {
                        char *s;
-                       (void)strncpy(path, file, sizeof(path));
+                       (void)strlcpy(path, file, sizeof(path));
                        s = strrchr(path, '/');
                        if (s != NULL) {
                                /* trim off trailing /'s */
@@ -900,7 +900,7 @@
                        }
                        if (hilo == HIGH_PIECE) {
                                if (s == NULL)
-                                       (void)strncpy(path, ".", sizeof(path));
+                                       (void)strlcpy(path, ".", sizeof(path));
                                else {
                                        while (s != path && s[0] == '/')
                                                *s-- = '\0';
@@ -909,7 +909,7 @@
                        }
                        else if (hilo == LOW_PIECE) {
                                if (s != NULL && s[1] != '\0')
-                                       (void)strncpy(path, s + 1,
+                                       (void)strlcpy(path, s + 1,
                                                      sizeof(path));
                                hilo = 0;
                        }



Home | Main Index | Thread Index | Old Index