Bug Report and patch fix
kapil jain
jainkkapil at gmail.com
Sun Aug 19 22:23:17 EST 2012
Hi
I found this issue in scp in the following blog link
http://oldpapyrus.wordpress.com/2012/08/08/scp-a-funny-error/
when the wrong local file name is specified in local to remote transfer
mode, scp first tries to establish the connection rather than to check
first whether the file is proper or not.
However I could not find a reported bug for this. I am attaching the fix as
patch for this issue.
Thanks
Kapil
http://jainkkapil.wordpress.com
-------------- next part --------------
? patch.txt
Index: scp.c
===================================================================
RCS file: /cvs/openssh/scp.c,v
retrieving revision 1.189
diff -u -r1.189 scp.c
--- scp.c 22 Sep 2011 11:38:01 -0000 1.189
+++ scp.c 19 Aug 2012 12:00:35 -0000
@@ -364,6 +364,7 @@
void tolocal(int, char *[]);
void toremote(char *, int, char *[]);
void usage(void);
+void verifypath(char *);
int
main(int argc, char **argv)
@@ -551,6 +552,18 @@
}
void
+verifypath(char *file)
+{
+ if (access(file, F_OK) == -1)
+ {
+ errno = ENOENT;
+ run_err("%s: %s",file,strerror(errno));
+ killchild(0);
+ }
+}
+
+
+void
toremote(char *targ, int argc, char **argv)
{
char *bp, *host, *src, *suser, *thost, *tuser, *arg;
@@ -656,6 +669,7 @@
if (remin == -1) {
xasprintf(&bp, "%s -t %s%s", cmd,
*targ == '-' ? "-- " : "", targ);
+ verifypath(argv[i]);/*added to check for the local existence of file before trying to do anything*/
host = cleanhostname(thost);
if (do_cmd(host, tuser, bp, &remin,
&remout) < 0)
More information about the openssh-unix-dev
mailing list