summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2014-01-09 03:26:00 +0000
committerguenther <guenther@openbsd.org>2014-01-09 03:26:00 +0000
commit3b5b09cec3d65c64d5acf140b17ddb40dc61bb93 (patch)
tree94a34ab544378f95a2ea61ed2ad049f2a895e4e6
parentSymlinks are displayed with '->', not '=>' (diff)
downloadwireguard-openbsd-3b5b09cec3d65c64d5acf140b17ddb40dc61bb93.tar.xz
wireguard-openbsd-3b5b09cec3d65c64d5acf140b17ddb40dc61bb93.zip
When formating the time for "ls -l"-style output, show dates in the future
with the year, and rearrange a comparison to avoid a potentional signed arithmetic overflow that would give the wrong result. ok djm@
-rw-r--r--usr.bin/ssh/sftp-common.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/ssh/sftp-common.c b/usr.bin/ssh/sftp-common.c
index ffc0166b042..ba73ba7c2a7 100644
--- a/usr.bin/ssh/sftp-common.c
+++ b/usr.bin/ssh/sftp-common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-common.c,v 1.25 2013/11/08 11:15:19 dtucker Exp $ */
+/* $OpenBSD: sftp-common.c,v 1.26 2014/01/09 03:26:00 guenther Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2001 Damien Miller. All rights reserved.
@@ -191,6 +191,7 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
char *user, *group;
char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1];
char sbuf[FMT_SCALED_STRSIZE];
+ time_t now;
strmode(st->st_mode, mode);
if (!remote) {
@@ -206,7 +207,9 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
group = gbuf;
}
if (ltime != NULL) {
- if (time(NULL) - st->st_mtime < (365*24*60*60)/2)
+ now = time(NULL);
+ if (now - (365*24*60*60)/2 < st->st_mtime &&
+ now >= st->st_mtime)
sz = strftime(tbuf, sizeof tbuf, "%b %e %H:%M", ltime);
else
sz = strftime(tbuf, sizeof tbuf, "%b %e %Y", ltime);