diff options
| author | dholland <dholland@NetBSD.org> | 2010-12-16 05:30:16 +0000 |
|---|---|---|
| committer | dholland <dholland@NetBSD.org> | 2010-12-16 05:30:16 +0000 |
| commit | ba5ed40009fc76bc4db62334d826ef0ea6fb47c9 (patch) | |
| tree | 4a145c56fb1f57015e2f19c507e16bfafcd3cede /usr.bin/stat/stat.c | |
| parent | 4992210acdec4a1ee7b7103d4f4707aa86c7343f (diff) | |
Use strlcpy, not strncpy, when the desired semantics are strlcpy's
rather than strncpy's.
Diffstat (limited to 'usr.bin/stat/stat.c')
| -rw-r--r-- | usr.bin/stat/stat.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/stat/stat.c b/usr.bin/stat/stat.c index 01e46b0a808..bf4a6c08e2f 100644 --- a/usr.bin/stat/stat.c +++ b/usr.bin/stat/stat.c @@ -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 @@ format1(const struct stat *st, 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 @@ format1(const struct stat *st, 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 @@ format1(const struct stat *st, } 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 @@ format1(const struct stat *st, } 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; } |
