diff options
Diffstat (limited to 'sftp-int.c')
-rw-r--r-- | sftp-int.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/sftp-int.c b/sftp-int.c index 3438fdeb0..42040f5bd 100644 --- a/sftp-int.c +++ b/sftp-int.c | |||
@@ -25,7 +25,7 @@ | |||
25 | /* XXX: recursive operations */ | 25 | /* XXX: recursive operations */ |
26 | 26 | ||
27 | #include "includes.h" | 27 | #include "includes.h" |
28 | RCSID("$OpenBSD: sftp-int.c,v 1.54 2003/01/13 11:04:04 djm Exp $"); | 28 | RCSID("$OpenBSD: sftp-int.c,v 1.55 2003/01/14 10:58:00 djm Exp $"); |
29 | 29 | ||
30 | #include "buffer.h" | 30 | #include "buffer.h" |
31 | #include "xmalloc.h" | 31 | #include "xmalloc.h" |
@@ -381,6 +381,17 @@ is_dir(char *path) | |||
381 | } | 381 | } |
382 | 382 | ||
383 | static int | 383 | static int |
384 | is_reg(char *path) | ||
385 | { | ||
386 | struct stat sb; | ||
387 | |||
388 | if (stat(path, &sb) == -1) | ||
389 | fatal("stat %s: %s", path, strerror(errno)); | ||
390 | |||
391 | return(S_ISREG(sb.st_mode)); | ||
392 | } | ||
393 | |||
394 | static int | ||
384 | remote_is_dir(struct sftp_conn *conn, char *path) | 395 | remote_is_dir(struct sftp_conn *conn, char *path) |
385 | { | 396 | { |
386 | Attrib *a; | 397 | Attrib *a; |
@@ -494,6 +505,12 @@ process_put(struct sftp_conn *conn, char *src, char *dst, char *pwd, int pflag) | |||
494 | 505 | ||
495 | /* Only one match, dst may be file, directory or unspecified */ | 506 | /* Only one match, dst may be file, directory or unspecified */ |
496 | if (g.gl_pathv[0] && g.gl_matchc == 1) { | 507 | if (g.gl_pathv[0] && g.gl_matchc == 1) { |
508 | if (!is_reg(g.gl_pathv[i])) { | ||
509 | error("Can't upload %s: not a regular file", | ||
510 | g.gl_pathv[0]); | ||
511 | err = 1; | ||
512 | goto out; | ||
513 | } | ||
497 | if (tmp_dst) { | 514 | if (tmp_dst) { |
498 | /* If directory specified, append filename */ | 515 | /* If directory specified, append filename */ |
499 | if (remote_is_dir(conn, tmp_dst)) { | 516 | 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) | |||
525 | } | 542 | } |
526 | 543 | ||
527 | for (i = 0; g.gl_pathv[i]; i++) { | 544 | for (i = 0; g.gl_pathv[i]; i++) { |
545 | if (!is_reg(g.gl_pathv[i])) { | ||
546 | error("skipping non-regular file %s", | ||
547 | g.gl_pathv[i]); | ||
548 | continue; | ||
549 | } | ||
528 | if (infer_path(g.gl_pathv[i], &tmp)) { | 550 | if (infer_path(g.gl_pathv[i], &tmp)) { |
529 | err = -1; | 551 | err = -1; |
530 | goto out; | 552 | goto out; |