summaryrefslogtreecommitdiff
path: root/sftp-common.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2017-10-04 11:23:58 +0100
committerColin Watson <cjwatson@debian.org>2017-10-04 11:23:58 +0100
commit62f54f20bf351468e0124f63cc2902ee40d9b0e9 (patch)
tree3e090f2711b94ca5029d3fa3e8047b1ed1448b1f /sftp-common.c
parent6fabaf6fd9b07cc8bc6a17c9c4a5b76849cfc874 (diff)
parent66bf74a92131b7effe49fb0eefe5225151869dc5 (diff)
Import openssh_7.6p1.orig.tar.gz
Diffstat (limited to 'sftp-common.c')
-rw-r--r--sftp-common.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/sftp-common.c b/sftp-common.c
index 3a70c52dd..13a7f5bec 100644
--- a/sftp-common.c
+++ b/sftp-common.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-common.c,v 1.29 2016/09/12 01:22:38 deraadt Exp $ */ 1/* $OpenBSD: sftp-common.c,v 1.30 2017/06/10 06:36:46 djm 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.
@@ -216,22 +216,21 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
216 int ulen, glen, sz = 0; 216 int ulen, glen, sz = 0;
217 struct tm *ltime = localtime(&st->st_mtime); 217 struct tm *ltime = localtime(&st->st_mtime);
218 char *user, *group; 218 char *user, *group;
219 char buf[1024], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1]; 219 char buf[1024], lc[8], mode[11+1], tbuf[12+1], ubuf[11+1], gbuf[11+1];
220 char sbuf[FMT_SCALED_STRSIZE]; 220 char sbuf[FMT_SCALED_STRSIZE];
221 time_t now; 221 time_t now;
222 222
223 strmode(st->st_mode, mode); 223 strmode(st->st_mode, mode);
224 if (!remote) { 224 if (remote) {
225 user = user_from_uid(st->st_uid, 0);
226 } else {
227 snprintf(ubuf, sizeof ubuf, "%u", (u_int)st->st_uid); 225 snprintf(ubuf, sizeof ubuf, "%u", (u_int)st->st_uid);
228 user = ubuf; 226 user = ubuf;
229 }
230 if (!remote) {
231 group = group_from_gid(st->st_gid, 0);
232 } else {
233 snprintf(gbuf, sizeof gbuf, "%u", (u_int)st->st_gid); 227 snprintf(gbuf, sizeof gbuf, "%u", (u_int)st->st_gid);
234 group = gbuf; 228 group = gbuf;
229 strlcpy(lc, "?", sizeof(lc));
230 } else {
231 user = user_from_uid(st->st_uid, 0);
232 group = group_from_gid(st->st_gid, 0);
233 snprintf(lc, sizeof(lc), "%u", (u_int)st->st_nlink);
235 } 234 }
236 if (ltime != NULL) { 235 if (ltime != NULL) {
237 now = time(NULL); 236 now = time(NULL);
@@ -247,12 +246,12 @@ ls_file(const char *name, const struct stat *st, int remote, int si_units)
247 glen = MAXIMUM(strlen(group), 8); 246 glen = MAXIMUM(strlen(group), 8);
248 if (si_units) { 247 if (si_units) {
249 fmt_scaled((long long)st->st_size, sbuf); 248 fmt_scaled((long long)st->st_size, sbuf);
250 snprintf(buf, sizeof buf, "%s %3u %-*s %-*s %8s %s %s", mode, 249 snprintf(buf, sizeof buf, "%s %3s %-*s %-*s %8s %s %s",
251 (u_int)st->st_nlink, ulen, user, glen, group, 250 mode, lc, ulen, user, glen, group,
252 sbuf, tbuf, name); 251 sbuf, tbuf, name);
253 } else { 252 } else {
254 snprintf(buf, sizeof buf, "%s %3u %-*s %-*s %8llu %s %s", mode, 253 snprintf(buf, sizeof buf, "%s %3s %-*s %-*s %8llu %s %s",
255 (u_int)st->st_nlink, ulen, user, glen, group, 254 mode, lc, ulen, user, glen, group,
256 (unsigned long long)st->st_size, tbuf, name); 255 (unsigned long long)st->st_size, tbuf, name);
257 } 256 }
258 return xstrdup(buf); 257 return xstrdup(buf);