summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2001-02-06 22:18:17 +0000
committerDamien Miller <djm@cvs.openbsd.org>2001-02-06 22:18:17 +0000
commita1492707868cbfc6f923067fa569a08a2b6d817e (patch)
tree51d0cfc11bd9463ea86e2ae068c7bc1f5b094fc4
parent303723b13d658c3fe1a861ba5c8972b50be382df (diff)
stat target for remote chdir before doing chdir
-rw-r--r--usr.bin/ssh/sftp-int.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/usr.bin/ssh/sftp-int.c b/usr.bin/ssh/sftp-int.c
index d4203869d60..7657210d116 100644
--- a/usr.bin/ssh/sftp-int.c
+++ b/usr.bin/ssh/sftp-int.c
@@ -27,7 +27,7 @@
/* XXX: recursive operations */
#include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.8 2001/02/06 05:22:02 provos Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.9 2001/02/06 22:18:16 djm Exp $");
#include "buffer.h"
#include "xmalloc.h"
@@ -477,6 +477,18 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd)
case I_CHDIR:
path1 = make_absolute(path1, *pwd);
tmp = do_realpath(in, out, path1);
+ aa = do_stat(in, out, tmp);
+ if (!(aa->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)) {
+ error("Can't change directory: Can't check target");
+ xfree(tmp);
+ break;
+ }
+ if (!S_ISDIR(aa->perm)) {
+ error("Can't change directory: \"%s\" is not "
+ "a directory", tmp);
+ xfree(tmp);
+ break;
+ }
if (tmp) {
xfree(*pwd);
*pwd = tmp;