librc: fix rc_runlevel_exists return for empty string
This function should return false if the runlevel is an empty string. X-Gentoo-Bug: 803536 X-Gentoo-Bug-URL: https://bugs.gentoo.org/803536 Closes: https://github.com/OpenRC/openrc/pull/431
This commit is contained in:
parent
dec9ef200b
commit
0a97bad6c9
@ -481,7 +481,8 @@ rc_runlevel_exists(const char *runlevel)
|
|||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
|
|
||||||
if (!runlevel || strcmp(runlevel, ".") == 0 || strcmp(runlevel, "..") == 0)
|
if (!runlevel || strcmp(runlevel, "") == 0 || 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))
|
||||||
|
Loading…
Reference in New Issue
Block a user