librc: do not allow "." and ".." as runlevel names
The rc_runlevel_exists function was attempting to treat "." and ".." as valid runlevels; however, this should not be allowed. X-Gentoo-Bug: 488710 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=488710
This commit is contained in:
@@ -425,7 +425,7 @@ rc_runlevel_exists(const char *runlevel)
|
|||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if (!runlevel)
|
if (!runlevel || strcmp(runlevel, ".") == 0 || strcmp(runlevel, "..") == 0)
|
||||||
return false;
|
return false;
|
||||||
snprintf(path, sizeof(path), "%s/%s", RC_RUNLEVELDIR, runlevel);
|
snprintf(path, sizeof(path), "%s/%s", RC_RUNLEVELDIR, runlevel);
|
||||||
if (stat(path, &buf) == 0 && S_ISDIR(buf.st_mode))
|
if (stat(path, &buf) == 0 && S_ISDIR(buf.st_mode))
|
||||||
|
Reference in New Issue
Block a user