diff options
Diffstat (limited to 'usr.bin/stat/stat.c')
-rw-r--r-- | usr.bin/stat/stat.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/stat/stat.c b/usr.bin/stat/stat.c index 950c76a..31e2bd9 100644 --- a/usr.bin/stat/stat.c +++ b/usr.bin/stat/stat.c @@ -30,7 +30,8 @@ #include <sys/cdefs.h> #if 0 #ifndef lint -__RCSID("$NetBSD: stat.c,v 1.30 2010/11/25 04:33:30 dholland Exp $"); +__RCSID("$NetBSD: stat.c,v 1.33 2011/01/15 22:54:10 njoly Exp $" +"$OpenBSD: stat.c,v 1.14 2009/06/24 09:44:25 sobrado Exp $"); #endif #endif @@ -226,7 +227,8 @@ main(int argc, char *argv[]) quiet = 1; } else { options = "f:FlLnqrst:x"; - synopsis = "[-FlLnqrsx] [-f format] [-t timefmt] [file ...]"; + synopsis = "[-FLnq] [-f format | -l | -r | -s | -x] " + "[-t timefmt] [file ...]"; } while ((ch = getopt(argc, argv, options)) != -1) @@ -729,6 +731,10 @@ format1(const struct stat *st, small = (sizeof(ts.tv_sec) == 4); data = ts.tv_sec; tm = localtime(&ts.tv_sec); + if (tm == NULL) { + ts.tv_sec = 0; + tm = localtime(&ts.tv_sec); + } (void)strftime(path, sizeof(path), timefmt, tm); sdata = path; formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | @@ -787,7 +793,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), " -> "); @@ -875,7 +881,7 @@ format1(const struct stat *st, case SHOW_filename: small = 0; data = 0; - (void)strncpy(path, file, sizeof(path)); + (void)strlcpy(path, file, sizeof(path)); sdata = path; formats = FMTF_STRING; if (ofmt == 0) |