diff options
author | mouring <mouring@cvs.openbsd.org> | 2004-01-23 17:57:49 +0000 |
---|---|---|
committer | mouring <mouring@cvs.openbsd.org> | 2004-01-23 17:57:49 +0000 |
commit | e398d76a8307454ceb3dbeab356adaf6a63e824c (patch) | |
tree | 5edf35477d2a25762ff29b2ffd34bca0a1705f08 /usr.bin | |
parent | 8c3e9f0a6d2b27a8f4f35bb3c672bf31106e9dd2 (diff) |
Fix issue pointed out with ls not handling large directories with embeded
paths correctly. OK damien@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/sftp-int.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.bin/ssh/sftp-int.c b/usr.bin/ssh/sftp-int.c index 5e84ce80952..7c33dd1f52f 100644 --- a/usr.bin/ssh/sftp-int.c +++ b/usr.bin/ssh/sftp-int.c @@ -25,7 +25,7 @@ /* XXX: recursive operations */ #include "includes.h" -RCSID("$OpenBSD: sftp-int.c,v 1.66 2004/01/13 09:25:05 djm Exp $"); +RCSID("$OpenBSD: sftp-int.c,v 1.67 2004/01/23 17:57:48 mouring Exp $"); #include <glob.h> @@ -597,17 +597,24 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag) if (!(lflag & SHORT_VIEW)) { int m = 0, width = 80; struct winsize ws; + char *tmp; /* Count entries for sort and find longest filename */ for (n = 0; d[n] != NULL; n++) m = MAX(m, strlen(d[n]->filename)); + /* Add any subpath that also needs to be counted */ + tmp = path_strip(path, strip_path); + m += strlen(tmp); + xfree(tmp); + if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) width = ws.ws_col; columns = width / (m + 2); columns = MAX(columns, 1); colspace = width / columns; + colspace = MIN(colspace, width); } qsort(d, n, sizeof(*d), sdirent_comp); |