diff options
Diffstat (limited to 'sftp-int.c')
-rw-r--r-- | sftp-int.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sftp-int.c b/sftp-int.c index 9c3ebe5bf..c236f6dac 100644 --- a/sftp-int.c +++ b/sftp-int.c | |||
@@ -28,7 +28,7 @@ | |||
28 | /* XXX: recursive operations */ | 28 | /* XXX: recursive operations */ |
29 | 29 | ||
30 | #include "includes.h" | 30 | #include "includes.h" |
31 | RCSID("$OpenBSD: sftp-int.c,v 1.20 2001/02/10 00:45:26 djm Exp $"); | 31 | RCSID("$OpenBSD: sftp-int.c,v 1.21 2001/02/12 20:53:33 stevesk Exp $"); |
32 | 32 | ||
33 | #include "buffer.h" | 33 | #include "buffer.h" |
34 | #include "xmalloc.h" | 34 | #include "xmalloc.h" |
@@ -293,7 +293,9 @@ parse_args(const char **cpp, int *pflag, unsigned long *n_arg, | |||
293 | char **path1, char **path2) | 293 | char **path1, char **path2) |
294 | { | 294 | { |
295 | const char *cmd, *cp = *cpp; | 295 | const char *cmd, *cp = *cpp; |
296 | char *cp2; | ||
296 | int base = 0; | 297 | int base = 0; |
298 | long l; | ||
297 | int i, cmdnum; | 299 | int i, cmdnum; |
298 | 300 | ||
299 | /* Skip leading whitespace */ | 301 | /* Skip leading whitespace */ |
@@ -387,18 +389,24 @@ parse_args(const char **cpp, int *pflag, unsigned long *n_arg, | |||
387 | /* Uses the rest of the line */ | 389 | /* Uses the rest of the line */ |
388 | break; | 390 | break; |
389 | case I_LUMASK: | 391 | case I_LUMASK: |
392 | base = 8; | ||
390 | case I_CHMOD: | 393 | case I_CHMOD: |
391 | base = 8; | 394 | base = 8; |
392 | case I_CHOWN: | 395 | case I_CHOWN: |
393 | case I_CHGRP: | 396 | case I_CHGRP: |
394 | /* Get numeric arg (mandatory) */ | 397 | /* Get numeric arg (mandatory) */ |
395 | if (*cp < '0' && *cp > '9') { | 398 | l = strtol(cp, &cp2, base); |
399 | if (cp2 == cp || ((l == LONG_MIN || l == LONG_MAX) && | ||
400 | errno == ERANGE) || l < 0) { | ||
396 | error("You must supply a numeric argument " | 401 | error("You must supply a numeric argument " |
397 | "to the %s command.", cmd); | 402 | "to the %s command.", cmd); |
398 | return(-1); | 403 | return(-1); |
399 | } | 404 | } |
400 | *n_arg = strtoul(cp, (char**)&cp, base); | 405 | cp = cp2; |
401 | if (!*cp || !strchr(WHITESPACE, *cp)) { | 406 | *n_arg = l; |
407 | if (cmdnum == I_LUMASK && strchr(WHITESPACE, *cp)) | ||
408 | break; | ||
409 | if (cmdnum == I_LUMASK || !strchr(WHITESPACE, *cp)) { | ||
402 | error("You must supply a numeric argument " | 410 | error("You must supply a numeric argument " |
403 | "to the %s command.", cmd); | 411 | "to the %s command.", cmd); |
404 | return(-1); | 412 | return(-1); |
@@ -530,6 +538,7 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd) | |||
530 | break; | 538 | break; |
531 | case I_LUMASK: | 539 | case I_LUMASK: |
532 | umask(n_arg); | 540 | umask(n_arg); |
541 | printf("Local umask: %03lo\n", n_arg); | ||
533 | break; | 542 | break; |
534 | case I_CHMOD: | 543 | case I_CHMOD: |
535 | path1 = make_absolute(path1, *pwd); | 544 | path1 = make_absolute(path1, *pwd); |