diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-02-07 00:10:19 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-02-07 00:10:19 +0000 |
commit | 180b19008c17998bd2bfad04c1ab9caf60dd9fd3 (patch) | |
tree | 3b46a76df3a917ae9def6001458240d8ac99d638 | |
parent | b6db09cd0152937bbaa058f8d8b16e26bd2a8445 (diff) |
check for stat failures, too; ok djm@
-rw-r--r-- | usr.bin/ssh/sftp-int.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/ssh/sftp-int.c b/usr.bin/ssh/sftp-int.c index 230b0648c61..f0bda640530 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.10 2001/02/06 23:55:20 markus Exp $"); +RCSID("$OpenBSD: sftp-int.c,v 1.11 2001/02/07 00:10:18 markus Exp $"); #include "buffer.h" #include "xmalloc.h" @@ -477,8 +477,12 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd) break; case I_CHDIR: path1 = make_absolute(path1, *pwd); - tmp = do_realpath(in, out, path1); - aa = do_stat(in, out, tmp); + if ((tmp = do_realpath(in, out, path1)) == NULL) + break; + if ((aa = do_stat(in, out, tmp)) == NULL) { + xfree(tmp); + break; + } if (!(aa->flags & SSH2_FILEXFER_ATTR_PERMISSIONS)) { error("Can't change directory: Can't check target"); xfree(tmp); @@ -490,10 +494,8 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd) xfree(tmp); break; } - if (tmp) { - xfree(*pwd); - *pwd = tmp; - } + xfree(*pwd); + *pwd = tmp; break; case I_LS: path1 = make_absolute(path1, *pwd); |