(wrong string) ée

From: <git_AT_suckless.org>
Date: Wed, 20 Apr 2016 23:57:48 +0200 (CEST)

commit dfc94e0221c0b830e49800e25e15c4ccad281b2c
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Sun Mar 27 14:49:45 2016 +0200
Commit: sin <sin_AT_2f30.org>
CommitDate: Wed Apr 20 22:57:40 2016 +0100

    ls: fix segfault when timestamp is out of range for struct tm
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/ls.c b/ls.c
index 3268a99..8cc285b 100644
--- a/ls.c
+++ b/ls.c
_AT_@ -118,6 +118,7 @@ output(const struct entry *ent)
 {
         struct group *gr;
         struct passwd *pw;
+ struct tm *tm;
         ssize_t len;
         size_t l;
         char *name, *c, *u, *fmt, buf[BUFSIZ],
_AT_@ -194,7 +195,10 @@ output(const struct entry *ent)
         else
                 fmt = "%b %d %H:%M";
 
- strftime(buf, sizeof(buf), fmt, localtime(&ent->t.tv_sec));
+ if ((tm = localtime(&ent->t.tv_sec)))
+ strftime(buf, sizeof(buf), fmt, tm);
+ else
+ snprintf(buf, sizeof(buf), "%lld", (long long)(ent->t.tv_sec));
         printf("%s %4ld %-8.8s %-8.8s ", mode, (long)ent->nlink, pwname, grname);
 
         if (S_ISBLK(ent->mode) || S_ISCHR(ent->mode))
Received on Wed Apr 20 2016 - 23:57:48 CEST

This archive was generated by hypermail 2.3.0 : Thu Apr 21 2016 - 00:00:54 CEST