Index: scp.c
===================================================================
RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/scp.c,v
retrieving revision 1.131
diff -u -p -r1.131 scp.c
--- scp.c	5 Nov 2004 09:10:02 -0000	1.131
+++ scp.c	9 Dec 2004 02:28:33 -0000
@@ -452,6 +452,23 @@ tolocal(int argc, char **argv)
 
 	for (i = 0; i < argc - 1; i++) {
 		if (!(src = colon(argv[i]))) {	/* Local to local. */
+			if (targetshouldbedirectory) {
+				struct stat stb;
+				int failed = 0;
+
+				if (stat(argv[argc - 1], &stb) == -1) {
+					failed = 1;
+				} else if (!S_ISDIR(stb.st_mode)) {
+					failed = 1;
+					errno = ENOTDIR;
+				}
+				if (failed) {
+					++errs;
+					fprintf(stderr, "scp: %s: %s\n",
+					   argv[argc - 1], strerror(errno));
+					break;
+				}
+			}
 			len = strlen(_PATH_CP) + strlen(argv[i]) +
 			    strlen(argv[argc - 1]) + 20;
 			bp = xmalloc(len);
