From 0a97bad6c9ba77285477aef8713e088eea4ab106 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Fri, 13 Aug 2021 10:28:44 -0500 Subject: 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 --- src/librc/librc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/librc/librc.c b/src/librc/librc.c index 9da1757f..f9bf5082 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -481,7 +481,8 @@ rc_runlevel_exists(const char *runlevel) char path[PATH_MAX]; struct stat buf; - if (!runlevel || strcmp(runlevel, ".") == 0 || strcmp(runlevel, "..") == 0) + if (!runlevel || strcmp(runlevel, "") == 0 || strcmp(runlevel, ".") == 0 || + strcmp(runlevel, "..") == 0) return false; snprintf(path, sizeof(path), "%s/%s", RC_RUNLEVELDIR, runlevel); if (stat(path, &buf) == 0 && S_ISDIR(buf.st_mode)) -- cgit v1.2.3