diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | sftp-common.c | 7 |
2 files changed, 11 insertions, 2 deletions
@@ -3,6 +3,12 @@ | |||
3 | - tedu@cvs.openbsd.org 2014/01/04 17:50:55 | 3 | - tedu@cvs.openbsd.org 2014/01/04 17:50:55 |
4 | [mac.c monitor_mm.c monitor_mm.h xmalloc.c] | 4 | [mac.c monitor_mm.c monitor_mm.h xmalloc.c] |
5 | use standard types and formats for size_t like variables. ok dtucker | 5 | use standard types and formats for size_t like variables. ok dtucker |
6 | - guenther@cvs.openbsd.org 2014/01/09 03:26:00 | ||
7 | [sftp-common.c] | ||
8 | When formating the time for "ls -l"-style output, show dates in the future | ||
9 | with the year, and rearrange a comparison to avoid a potentional signed | ||
10 | arithmetic overflow that would give the wrong result. | ||
11 | ok djm@ | ||
6 | 12 | ||
7 | 20140108 | 13 | 20140108 |
8 | - (djm) [regress/.cvsignore] Ignore regress test droppings; ok dtucker@ | 14 | - (djm) [regress/.cvsignore] Ignore regress test droppings; ok dtucker@ |
diff --git a/sftp-common.c b/sftp-common.c index 88bf51bc6..70a929ccc 100644 --- a/sftp-common.c +++ b/sftp-common.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sftp-common.c,v 1.25 2013/11/08 11:15:19 dtucker Exp $ */ | 1 | /* $OpenBSD: sftp-common.c,v 1.26 2014/01/09 03:26:00 guenther Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. | 3 | * Copyright (c) 2001 Markus Friedl. All rights reserved. |
4 | * Copyright (c) 2001 Damien Miller. All rights reserved. | 4 | * Copyright (c) 2001 Damien Miller. All rights reserved. |
@@ -195,6 +195,7 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units) | |||
195 | char *user, *group; | 195 | char *user, *group; |
196 | char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1]; | 196 | char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1]; |
197 | char sbuf[FMT_SCALED_STRSIZE]; | 197 | char sbuf[FMT_SCALED_STRSIZE]; |
198 | time_t now; | ||
198 | 199 | ||
199 | strmode(st->st_mode, mode); | 200 | strmode(st->st_mode, mode); |
200 | if (!remote) { | 201 | if (!remote) { |
@@ -210,7 +211,9 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units) | |||
210 | group = gbuf; | 211 | group = gbuf; |
211 | } | 212 | } |
212 | if (ltime != NULL) { | 213 | if (ltime != NULL) { |
213 | if (time(NULL) - st->st_mtime < (365*24*60*60)/2) | 214 | now = time(NULL); |
215 | if (now - (365*24*60*60)/2 < st->st_mtime && | ||
216 | now >= st->st_mtime) | ||
214 | sz = strftime(tbuf, sizeof tbuf, "%b %e %H:%M", ltime); | 217 | sz = strftime(tbuf, sizeof tbuf, "%b %e %H:%M", ltime); |
215 | else | 218 | else |
216 | sz = strftime(tbuf, sizeof tbuf, "%b %e %Y", ltime); | 219 | sz = strftime(tbuf, sizeof tbuf, "%b %e %Y", ltime); |