From a9fc26ac1367ac887eab76007e8834dfe787edcd Mon Sep 17 00:00:00 2001 From: philhofer Date: Sun, 23 Dec 2018 12:42:33 -0800 Subject: src/rc/supervise-daemon.c: do not pass NULL to strcmp The following will cause a segfault due to NULL being passed to strcmp(3) $ RC_SVCNAME=foo supervise-daemon Fix the bounds check on argc in main. If argc<=1, then it is not safe to dereference argv[1]. --- src/rc/supervise-daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index bf958607..fec85594 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -720,7 +720,7 @@ int main(int argc, char **argv) eerrorx("%s: The RC_SVCNAME environment variable is not set", applet); openlog(applet, LOG_PID, LOG_DAEMON); - if (argc >= 1 && svcname && strcmp(argv[1], svcname)) + if (argc <= 1 || strcmp(argv[1], svcname)) eerrorx("%s: the first argument is %s and must be %s", applet, argv[1], svcname); -- cgit v1.2.3