summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2017-06-10 06:36:47 +0000
committerDamien Miller <djm@cvs.openbsd.org>2017-06-10 06:36:47 +0000
commit35578db8791ae58bcfa5e7fc6169f2078e825fb2 (patch)
treefe7fa963073b85127b3bacb3d020a45bc03afa1f /usr.bin/ssh
parent94dcd6899b59962f46b004232ef4064297f500e0 (diff)
print '?' instead of incorrect link count (that the protocol doesn't
provide) for remote listings. bz#2710 ok dtucker@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/sftp-common.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/usr.bin/ssh/sftp-common.c b/usr.bin/ssh/sftp-common.c
index 6706fb4cbdc..c62940441cc 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.29 2016/09/12 01:22:38 deraadt Exp $ */
+/* $OpenBSD: sftp-common.c,v 1.30 2017/06/10 06:36:46 djm Exp $ */
/*
* Copyright (c) 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2001 Damien Miller. All rights reserved.
@@ -212,22 +212,21 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
int ulen, glen, sz = 0;
struct tm *ltime = localtime(&st->st_mtime);
char *user, *group;
- char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1];
+ char buf[1024], lc[8], 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) {
- user = user_from_uid(st->st_uid, 0);
- } else {
+ if (remote) {
snprintf(ubuf, sizeof ubuf, "%u", (u_int)st->st_uid);
user = ubuf;
- }
- if (!remote) {
- group = group_from_gid(st->st_gid, 0);
- } else {
snprintf(gbuf, sizeof gbuf, "%u", (u_int)st->st_gid);
group = gbuf;
+ strlcpy(lc, "?", sizeof(lc));
+ } else {
+ user = user_from_uid(st->st_uid, 0);
+ group = group_from_gid(st->st_gid, 0);
+ snprintf(lc, sizeof(lc), "%u", (u_int)st->st_nlink);
}
if (ltime != NULL) {
now = time(NULL);
@@ -243,12 +242,12 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
glen = MAXIMUM(strlen(group), 8);
if (si_units) {
fmt_scaled((long long)st->st_size, sbuf);
- snprintf(buf, sizeof buf, "%s %3u %-*s %-*s %8s %s %s", mode,
- (u_int)st->st_nlink, ulen, user, glen, group,
+ snprintf(buf, sizeof buf, "%s %3s %-*s %-*s %8s %s %s",
+ mode, lc, ulen, user, glen, group,
sbuf, tbuf, name);
} else {
- snprintf(buf, sizeof buf, "%s %3u %-*s %-*s %8llu %s %s", mode,
- (u_int)st->st_nlink, ulen, user, glen, group,
+ snprintf(buf, sizeof buf, "%s %3s %-*s %-*s %8llu %s %s",
+ mode, lc, ulen, user, glen, group,
(unsigned long long)st->st_size, tbuf, name);
}
return xstrdup(buf);