mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-10-31 13:10:35 +00:00
Tighten check on TFTP pathnames to avoid directory escape.
This commit is contained in:
1 file changed
+7
-2
+7
-2
@@ -545,8 +545,13 @@ static struct tftp_file *check_tftp_fileperm(char *packet, ssize_t *len, char *p
|
||||
int fd = -1;
|
||||
|
||||
/* trick to ban moving out of the subtree */
|
||||
if (prefix && strstr(namebuff, "/../"))
|
||||
goto perm;
|
||||
if (prefix)
|
||||
{
|
||||
char *suspect = strstr(namebuff, "/..");
|
||||
|
||||
if (suspect && (suspect[3] == '/' || suspect[3] == 0))
|
||||
goto perm;
|
||||
}
|
||||
|
||||
if ((fd = open(namebuff, O_RDONLY)) == -1)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user