diff options
author | Damien Miller <djm@mindrot.org> | 2003-01-14 22:24:47 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2003-01-14 22:24:47 +1100 |
commit | 5fa01fd7fba87bbd716b4ca32d4d7e2f7180975a (patch) | |
tree | 68a78059ae0fb2036c739bcb0e479689e87a6532 /sftp-int.c | |
parent | 7a992387cb9a14fbe9b1a1108bd41c8cb1ccd38a (diff) | |
download | openssh-git-5fa01fd7fba87bbd716b4ca32d4d7e2f7180975a.tar.gz |
- djm@cvs.openbsd.org 2003/01/14 10:58:00
[sftp-client.c sftp-int.c]
Don't try to upload or download non-regular files. Report from
apoloval@pantuflo.escet.urjc.es; ok markus@
Diffstat (limited to 'sftp-int.c')
-rw-r--r-- | sftp-int.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -25,7 +25,7 @@ /* XXX: recursive operations */ #include "includes.h" -RCSID("$OpenBSD: sftp-int.c,v 1.54 2003/01/13 11:04:04 djm Exp $"); +RCSID("$OpenBSD: sftp-int.c,v 1.55 2003/01/14 10:58:00 djm Exp $"); #include "buffer.h" #include "xmalloc.h" @@ -381,6 +381,17 @@ is_dir(char *path) } static int +is_reg(char *path) +{ + struct stat sb; + + if (stat(path, &sb) == -1) + fatal("stat %s: %s", path, strerror(errno)); + + return(S_ISREG(sb.st_mode)); +} + +static int remote_is_dir(struct sftp_conn *conn, char *path) { Attrib *a; @@ -494,6 +505,12 @@ process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag) /* Only one match, dst may be file, directory or unspecified */ if (g.gl_pathv[0] && g.gl_matchc == 1) { + if (!is_reg(g.gl_pathv[i])) { + error("Can't upload %s: not a regular file", + g.gl_pathv[0]); + err = 1; + goto out; + } if (tmp_dst) { /* If directory specified, append filename */ if (remote_is_dir(conn, tmp_dst)) { @@ -525,6 +542,11 @@ process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag) } for (i = 0; g.gl_pathv[i]; i++) { + if (!is_reg(g.gl_pathv[i])) { + error("skipping non-regular file %s", + g.gl_pathv[i]); + continue; + } if (infer_path(g.gl_pathv[i], &tmp)) { err = -1; goto out; |