summaryrefslogtreecommitdiff
path: root/sftp-int.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2004-01-27 21:20:11 +1100
committerDamien Miller <djm@mindrot.org>2004-01-27 21:20:11 +1100
commitb21be844711ff285ba24cf70bfb2c7238f60c1cc (patch)
treed08dd8569da88e7328049ba552a358e5cf9c3f17 /sftp-int.c
parent4f0fe684daa4f35e1c91224e144c91b4869946fa (diff)
- mouring@cvs.openbsd.org 2004/01/23 17:57:48
[sftp-int.c] Fix issue pointed out with ls not handling large directories with embeded paths correctly. OK damien@
Diffstat (limited to 'sftp-int.c')
-rw-r--r--sftp-int.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sftp-int.c b/sftp-int.c
index a9423fe69..3ee57515d 100644
--- a/sftp-int.c
+++ b/sftp-int.c
@@ -25,7 +25,7 @@
25/* XXX: recursive operations */ 25/* XXX: recursive operations */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: sftp-int.c,v 1.66 2004/01/13 09:25:05 djm Exp $"); 28RCSID("$OpenBSD: sftp-int.c,v 1.67 2004/01/23 17:57:48 mouring Exp $");
29 29
30#include "buffer.h" 30#include "buffer.h"
31#include "xmalloc.h" 31#include "xmalloc.h"
@@ -595,17 +595,24 @@ do_ls_dir(struct sftp_conn *conn, char *path, char *strip_path, int lflag)
595 if (!(lflag & SHORT_VIEW)) { 595 if (!(lflag & SHORT_VIEW)) {
596 int m = 0, width = 80; 596 int m = 0, width = 80;
597 struct winsize ws; 597 struct winsize ws;
598 char *tmp;
598 599
599 /* Count entries for sort and find longest filename */ 600 /* Count entries for sort and find longest filename */
600 for (n = 0; d[n] != NULL; n++) 601 for (n = 0; d[n] != NULL; n++)
601 m = MAX(m, strlen(d[n]->filename)); 602 m = MAX(m, strlen(d[n]->filename));
602 603
604 /* Add any subpath that also needs to be counted */
605 tmp = path_strip(path, strip_path);
606 m += strlen(tmp);
607 xfree(tmp);
608
603 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1) 609 if (ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)
604 width = ws.ws_col; 610 width = ws.ws_col;
605 611
606 columns = width / (m + 2); 612 columns = width / (m + 2);
607 columns = MAX(columns, 1); 613 columns = MAX(columns, 1);
608 colspace = width / columns; 614 colspace = width / columns;
615 colspace = MIN(colspace, width);
609 } 616 }
610 617
611 qsort(d, n, sizeof(*d), sdirent_comp); 618 qsort(d, n, sizeof(*d), sdirent_comp);