Check the given path for ".."

This commit is contained in:
Stefano Ceccherini 2013-11-09 21:32:35 +01:00
parent 5ae9ef055c
commit f05b8e3873
1 changed files with 6 additions and 3 deletions

View File

@ -118,10 +118,13 @@ ethernet_link_checker(void *)
status_t
ethernet_init(const char *name, net_device **_device)
{
// make sure this is a device in /dev/net, but not the
// networking (userland) stack driver
// Make sure this is a device in /dev/net, but not the
// networking (userland) stack driver.
// Also make sure the user didn't pass a path like
// /dev/net/../etc.
if (strncmp(name, "/dev/net/", 9)
|| !strcmp(name, "/dev/net/userland_server"))
|| !strcmp(name, "/dev/net/userland_server")
|| strstr(name, "..") != NULL)
return B_BAD_VALUE;
if (access(name, F_OK) != 0)