Tighten check on TFTP pathnames to avoid directory escape.

This commit is contained in:
Simon Kelley committed 2026-03-30 21:18:11 +01:00
1 parent e0bec3342b
commit d152e81e42
1 file changed
+7 -2
+7 -2
View File
@@ -545,8 +545,13 @@ static struct tftp_file *check_tftp_fileperm(char *packet, ssize_t *len, char *p
int fd = -1; int fd = -1;
/* trick to ban moving out of the subtree */ /* trick to ban moving out of the subtree */
if (prefix && strstr(namebuff, "/../")) if (prefix)
goto perm; {
char *suspect = strstr(namebuff, "/..");
if (suspect && (suspect[3] == '/' || suspect[3] == 0))
goto perm;
}
if ((fd = open(namebuff, O_RDONLY)) == -1) if ((fd = open(namebuff, O_RDONLY)) == -1)
{ {