10c4fc
From 6010c0303a422a9c5fa8860c061bf7105eb7f8b2 Mon Sep 17 00:00:00 2001
10c4fc
From: "djm@openbsd.org" <djm@openbsd.org>
10c4fc
Date: Fri, 16 Nov 2018 03:03:10 +0000
10c4fc
Subject: [PATCH] upstream: disallow empty incoming filename or ones that refer
10c4fc
 to the
10c4fc
10c4fc
current directory; based on report/patch from Harry Sintonen
10c4fc
10c4fc
OpenBSD-Commit-ID: f27651b30eaee2df49540ab68d030865c04f6de9
10c4fc
---
10c4fc
 scp.c | 5 +++--
10c4fc
 1 file changed, 3 insertions(+), 2 deletions(-)
10c4fc
10c4fc
diff --git a/scp.c b/scp.c
10c4fc
index 60682c687..4f3fdcd3d 100644
10c4fc
--- a/scp.c
10c4fc
+++ b/scp.c
10c4fc
@@ -1106,7 +1106,8 @@ sink(int argc, char **argv)
10c4fc
 			SCREWUP("size out of range");
10c4fc
 		size = (off_t)ull;
10c4fc
 
10c4fc
-		if ((strchr(cp, '/') != NULL) || (strcmp(cp, "..") == 0)) {
10c4fc
+		if (*cp == '\0' || strchr(cp, '/') != NULL ||
10c4fc
+		    strcmp(cp, ".") == 0 || strcmp(cp, "..") == 0) {
10c4fc
 			run_err("error: unexpected filename: %s", cp);
10c4fc
 			exit(1);
10c4fc
 		}
10c4fc