diff options
author | 2004-01-23 17:57:48 +0000 | |
---|---|---|
committer | 2004-01-23 17:57:48 +0000 | |
commit | 0102ceaffca612ecd9445a783c480bb1ae647187 (patch) | |
tree | 908405ab576c582355422a8da4a7d44c9b830fdc | |
parent | Get rid of a few (mostly DDB related) unused defines and macros. (diff) | |
download | wireguard-openbsd-0102ceaffca612ecd9445a783c480bb1ae647187.tar.xz wireguard-openbsd-0102ceaffca612ecd9445a783c480bb1ae647187.zip |
Fix issue pointed out with ls not handling large directories with embeded
paths correctly. OK damien@
-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); |