diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2003-02-02 10:51:14 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2003-02-02 10:51:14 +0000 |
commit | 36e2b90f89ee970bd865db4cbc721fa907b419a8 (patch) | |
tree | a4bcdc3ce102588e3950b13db15803953592f679 | |
parent | 18c2fd12c7ba8130ed965491230ca6ed9e37a8e5 (diff) |
call okname() only when using system(3) for remote-remote copy;
fixes bugs #483, #472; ok deraadt@, mouring@
-rw-r--r-- | usr.bin/ssh/scp.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c index 351597f0203..2c6f523e728 100644 --- a/usr.bin/ssh/scp.c +++ b/usr.bin/ssh/scp.c @@ -75,7 +75,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: scp.c,v 1.100 2003/01/23 14:06:15 markus Exp $"); +RCSID("$OpenBSD: scp.c,v 1.101 2003/02/02 10:51:13 markus Exp $"); #include "xmalloc.h" #include "atomicio.h" @@ -361,8 +361,6 @@ toremote(targ, argc, argv) tuser = argv[argc - 1]; if (*tuser == '\0') tuser = NULL; - else if (!okname(tuser)) - exit(1); } else { thost = argv[argc - 1]; tuser = NULL; @@ -390,6 +388,8 @@ toremote(targ, argc, argv) suser = pwd->pw_name; else if (!okname(suser)) continue; + if (tuser && !okname(tuser)) + continue; snprintf(bp, len, "%s%s %s -n " "-l %s %s %s %s '%s%s%s:%s'", @@ -463,8 +463,6 @@ tolocal(argc, argv) suser = argv[i]; if (*suser == '\0') suser = pwd->pw_name; - else if (!okname(suser)) - continue; } host = cleanhostname(host); len = strlen(src) + CMDNEEDS + 20; @@ -1061,9 +1059,18 @@ okname(cp0) c = (int)*cp; if (c & 0200) goto bad; - if (!isalpha(c) && !isdigit(c) && - c != '@' && c != '_' && c != '-' && c != '.' && c != '+') - goto bad; + if (!isalpha(c) && !isdigit(c)) { + switch (c) { + case '\'': + case '"': + case '`': + case ' ': + case '#': + goto bad; + default: + break; + } + } } while (*++cp); return (1); |