scp.c: Port OpenSSH CVE-2018-20685 fix (#80)

This commit is contained in:
Haelwenn Monnier 2020-05-25 14:54:29 +02:00 committed by GitHub
parent 90cfbe1f7a
commit 8f8a3dff70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

3
scp.c
View File

@ -935,7 +935,8 @@ sink(int argc, char **argv)
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);
}