summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2001-02-07 13:12:29 +0000
committerdjm <djm@openbsd.org>2001-02-07 13:12:29 +0000
commit0768650941f2603c861d991ab8fc7338ce7b84e0 (patch)
tree1c6423e71e365996fe2a761416be4b1b79a30092
parentdd ECONNABORTED. (diff)
downloadwireguard-openbsd-0768650941f2603c861d991ab8fc7338ce7b84e0.tar.xz
wireguard-openbsd-0768650941f2603c861d991ab8fc7338ce7b84e0.zip
Check that target is a directory before doing ls; ok markus@
-rw-r--r--usr.bin/ssh/sftp-int.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/usr.bin/ssh/sftp-int.c b/usr.bin/ssh/sftp-int.c
index f0bda640530..786c5141037 100644
--- a/usr.bin/ssh/sftp-int.c
+++ b/usr.bin/ssh/sftp-int.c
@@ -24,10 +24,11 @@
/* XXX: finish implementation of all commands */
/* XXX: do fnmatch() instead of using raw pathname */
+/* XXX: globbed ls */
/* XXX: recursive operations */
#include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.11 2001/02/07 00:10:18 markus Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.12 2001/02/07 13:12:29 djm Exp $");
#include "buffer.h"
#include "xmalloc.h"
@@ -498,8 +499,23 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd)
*pwd = tmp;
break;
case I_LS:
+ if (!path1) {
+ do_ls(in, out, *pwd);
+ break;
+ }
path1 = make_absolute(path1, *pwd);
- do_ls(in, out, path1?path1:*pwd);
+ if ((tmp = do_realpath(in, out, path1)) == NULL)
+ break;
+ xfree(path1);
+ path1 = tmp;
+ if ((aa = do_stat(in, out, path1)) == NULL)
+ break;
+ if ((aa->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) &&
+ !S_ISDIR(aa->perm)) {
+ error("Can't ls: \"%s\" is not a directory", path1);
+ break;
+ }
+ do_ls(in, out, path1);
break;
case I_LCHDIR:
if (chdir(path1) == -1)