instance: exit in case asprintf() fails
authorDaniel Golle <daniel@makrotopia.org>
Fri, 18 Feb 2022 20:41:02 +0000 (20:41 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 18 Feb 2022 20:44:34 +0000 (20:44 +0000)
If asprintf returns -1 we are most likely out of memory, so just exit
in that case.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
service/instance.c

index 9c74265dc4fa92f729aa728c636033856ebdbea0..8202d65129a151fc47c6aacdfa268fdd3c7ccbf0 100644 (file)
@@ -295,7 +295,9 @@ jail_run(struct service_instance *in, char **argv)
 
        argv[argc++] = UJAIL_BIN_PATH;
 
-       asprintf(&term_timeout_str, "%d", in->term_timeout);
+       if (asprintf(&term_timeout_str, "%d", in->term_timeout) == -1)
+               exit(ENOMEM);
+
        argv[argc++] = "-t";
        argv[argc++] = term_timeout_str;