[openssh-commits] [openssh] 05/10: upstream commit
git+noreply at mindrot.org
git+noreply at mindrot.org
Tue Dec 19 16:18:18 AEDT 2017
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit c9e37a8725c083441dd34a8a53768aa45c3c53fe
Author: millert at openbsd.org <millert at openbsd.org>
Date: Mon Dec 18 17:28:54 2017 +0000
upstream commit
Add helper function for uri handing in scp where a
missing path simply means ".". Also fix exit code and add warnings when an
invalid uri is encountered. OK otto@
OpenBSD-Commit-ID: 47dcf872380586dabf7fcc6e7baf5f8ad508ae1a
---
scp.c | 47 ++++++++++++++++++++++++++++++++++++-----------
1 file changed, 36 insertions(+), 11 deletions(-)
diff --git a/scp.c b/scp.c
index 2103a54e..9f99709b 100644
--- a/scp.c
+++ b/scp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scp.c,v 1.193 2017/10/21 23:06:24 millert Exp $ */
+/* $OpenBSD: scp.c,v 1.194 2017/12/18 17:28:54 millert Exp $ */
/*
* scp - secure remote copy. This is basically patched BSD rcp which
* uses ssh to do the data transfer (instead of using rcmd).
@@ -606,6 +606,18 @@ do_times(int fd, int verb, const struct stat *sb)
return (response());
}
+static int
+parse_scp_uri(const char *uri, char **userp, char **hostp, int *portp,
+ char **pathp)
+{
+ int r;
+
+ r = parse_uri("scp", uri, userp, hostp, portp, pathp);
+ if (r == 0 && *pathp == NULL)
+ *pathp = xstrdup(".");
+ return r;
+}
+
void
toremote(int argc, char **argv)
{
@@ -620,27 +632,39 @@ toremote(int argc, char **argv)
alist.list = NULL;
/* Parse target */
- r = parse_uri("scp", argv[argc - 1], &tuser, &thost, &tport, &targ);
- if (r == -1)
- goto out; /* invalid URI */
+ r = parse_scp_uri(argv[argc - 1], &tuser, &thost, &tport, &targ);
+ if (r == -1) {
+ fmprintf(stderr, "%s: invalid uri\n", argv[argc - 1]);
+ ++errs;
+ goto out;
+ }
if (r != 0) {
if (parse_user_host_path(argv[argc - 1], &tuser, &thost,
- &targ) == -1)
+ &targ) == -1) {
+ fmprintf(stderr, "%s: invalid target\n", argv[argc - 1]);
+ ++errs;
goto out;
+ }
}
- if (tuser != NULL && !okname(tuser))
+ if (tuser != NULL && !okname(tuser)) {
+ ++errs;
goto out;
+ }
/* Parse source files */
for (i = 0; i < argc - 1; i++) {
free(suser);
free(host);
free(src);
- r = parse_uri("scp", argv[i], &suser, &host, &sport, &src);
- if (r == -1)
- continue; /* invalid URI */
- if (r != 0)
+ r = parse_scp_uri(argv[i], &suser, &host, &sport, &src);
+ if (r == -1) {
+ fmprintf(stderr, "%s: invalid uri\n", argv[i]);
+ ++errs;
+ continue;
+ }
+ if (r != 0) {
parse_user_host_path(argv[i], &suser, &host, &src);
+ }
if (suser != NULL && !okname(suser)) {
++errs;
continue;
@@ -730,8 +754,9 @@ tolocal(int argc, char **argv)
free(suser);
free(host);
free(src);
- r = parse_uri("scp", argv[i], &suser, &host, &sport, &src);
+ r = parse_scp_uri(argv[i], &suser, &host, &sport, &src);
if (r == -1) {
+ fmprintf(stderr, "%s: invalid uri\n", argv[i]);
++errs;
continue;
}
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list