]> andersk Git - openssh.git/blobdiff - sftp-int.c
- (bal) auth1.c minor resync while looking at the code.
[openssh.git] / sftp-int.c
index 3438fdeb003192180c69dc425e36ffebcdcf33f5..6987de9a3888729901f376e6dc4e4d0017221dc9 100644 (file)
@@ -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.57 2003/03/05 22:33:43 markus Exp $");
 
 #include "buffer.h"
 #include "xmalloc.h"
@@ -380,6 +380,17 @@ is_dir(char *path)
        return(sb.st_mode & S_IFDIR);
 }
 
+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)
 {
@@ -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[0])) {
+                       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;
@@ -1082,6 +1104,7 @@ interactive_loop(int fd_in, int fd_out, char *file1, char *file2)
 
                        err = parse_dispatch_command(conn, cmd, &pwd, 1);
                        xfree(dir);
+                       xfree(pwd);
                        return (err);
                }
                xfree(dir);
This page took 0.034696 seconds and 4 git commands to generate.