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