mirror of
https://github.com/troglobit/finit.git
synced 2026-10-12 10:12:32 +00:00
Fix possible NULL ptr deref, found by Coverity Scan
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+6
-2
@@ -1227,7 +1227,11 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
if (tty_parse_args(cmd, &tty))
|
||||
return errno;
|
||||
|
||||
len += strlen(tty.cmd) + tty.num + 1;
|
||||
if (tty.cmd)
|
||||
len += strlen(tty.cmd);
|
||||
else
|
||||
len += 3;
|
||||
len += tty.num + 1;
|
||||
for (i = 0; i < tty.num; i++)
|
||||
len += strlen(tty.args[i]) + 1;
|
||||
|
||||
@@ -1235,7 +1239,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
|
||||
if (!line)
|
||||
return errno;
|
||||
|
||||
snprintf(line, len, "%s", tty.cmd);
|
||||
snprintf(line, len, "%s", tty.cmd ? tty.cmd : "tty");
|
||||
for (i = 0; i < tty.num; i++) {
|
||||
strlcat(line, " ", len);
|
||||
strlcat(line, tty.args[i], len);
|
||||
|
||||
Reference in New Issue
Block a user