--- openssh-3.8.1p1.orig/scp.c	2003-11-24 03:09:28.000000000 +0100
+++ openssh-3.8.1p1/scp.c	2005-07-26 11:23:21.000000000 +0200
@@ -364,11 +364,46 @@
 {
 	int i, len;
 	char *bp, *host, *src, *suser, *thost, *tuser;
+        char *quote_targ = 0;
 
 	*targ++ = 0;
 	if (*targ == 0)
 		targ = ".";
 
+        {
+          int c, qc;
+
+          if (verbose_mode)
+            fprintf(stderr, "Unquoted target: \"%s\"\n", targ);
+          quote_targ = xmalloc(strlen(targ)*2+1);
+          for (c=qc=0; c < strlen(targ); c++, qc++) {
+            switch (targ[c]) {
+            case ' ':
+            case ':':
+            case '(':
+            case ')':
+            case '[':
+            case ']':
+            case '<':
+            case '>':
+            case ';':
+            case '|':
+            case '&':
+            case '\\':
+              quote_targ[qc] = '\\';
+              qc++;
+              break;
+            default:
+              break;
+            }
+            quote_targ[qc] = targ[c];
+          }
+          quote_targ[qc] = 0;
+          targ = quote_targ;
+          if (verbose_mode)
+            fprintf(stderr, "Quoted target = \"%s\"\n", targ);
+        }
+
 	if ((thost = strrchr(argv[argc - 1], '@'))) {
 		/* user@host */
 		*thost++ = 0;
@@ -446,6 +481,8 @@
 			source(1, argv + i);
 		}
 	}
+        if (quote_targ)
+          xfree(quote_targ);
 }
 
 void
@@ -453,6 +490,7 @@
 {
 	int i, len;
 	char *bp, *host, *src, *suser;
+        char *quote_src = 0;
 
 	for (i = 0; i < argc - 1; i++) {
 		if (!(src = colon(argv[i]))) {	/* Local to local. */
@@ -472,6 +510,41 @@
 		*src++ = 0;
 		if (*src == 0)
 			src = ".";
+
+                {
+                  int c, qc;
+
+                  if (verbose_mode)
+                    fprintf(stderr, "Unquoted source: \"%s\"\n", src);
+                  quote_src = xmalloc(strlen(src)*2+1);
+                  for (c=qc=0; c < strlen(src); c++, qc++) {
+                    switch (src[c]) {
+                    case ' ':
+                    case ':':
+                    case '(':
+                    case ')':
+                    case '[':
+                    case ']':
+                    case '<':
+                    case '>':
+                    case ';':
+                    case '|':
+                    case '&':
+                    case '\\':
+                      quote_src[qc] = '\\';
+                      qc++;
+                      break;
+                    default:
+                      break;
+                    }
+                    quote_src[qc] = src[c];
+                  }
+                  quote_src[qc] = 0;
+                  src = quote_src;
+                  if (verbose_mode)
+                    fprintf(stderr, "Quoted source = \"%s\"\n", src);
+                }
+
 		if ((host = strrchr(argv[i], '@')) == NULL) {
 			host = argv[i];
 			suser = NULL;
@@ -495,6 +568,8 @@
 		(void) close(remin);
 		remin = remout = -1;
 	}
+        if (quote_src)
+          xfree(quote_src);
 }
 
 void
