diff scp.c @ 1669:3080aed32bf1

scp.c: Port OpenSSH CVE-2018-20685 fix (#80)
author Haelwenn Monnier <contact+github.com@hacktivis.me>
date Mon, 25 May 2020 14:54:29 +0200
parents 750ec4ec4cbe
children 401d7d8c8a79
line wrap: on
line diff
--- a/scp.c	Fri Mar 27 23:23:11 2020 +0800
+++ b/scp.c	Mon May 25 14:54:29 2020 +0200
@@ -935,7 +935,8 @@
 			size = size * 10 + (*cp++ - '0');
 		if (*cp++ != ' ')
 			SCREWUP("size not delimited");
-		if ((strchr(cp, '/') != NULL) || (strcmp(cp, "..") == 0)) {
+		if (*cp == '\0' || strchr(cp, '/') != NULL ||
+		    strcmp(cp, ".") == 0 || strcmp(cp, "..") == 0) {
 			run_err("error: unexpected filename: %s", cp);
 			exit(1);
 		}