summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2021-08-04 14:53:07 +0000
committerDaniel Golle2021-08-04 14:53:07 +0000
commit78d5baa015105d4f1da9499a6bbb0364843083b1 (patch)
tree312bc98ebbf190d2ef74441f00fee6b3fa0ebf8a
parent220b7160dbabe39a562b5e6cbd43acc1bc9f8e06 (diff)
downloadprocd-78d5baa015105d4f1da9499a6bbb0364843083b1.tar.gz
hotplug-dispatch: don't ignore asprintf() return value
Properly handle asprintf() return value and error out on -1. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--hotplug-dispatch.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hotplug-dispatch.c b/hotplug-dispatch.c
index 6a4fa68..0a285c9 100644
--- a/hotplug-dispatch.c
+++ b/hotplug-dispatch.c
@@ -105,7 +105,11 @@ static void hotplug_exec(struct uloop_timeout *t)
return;
}
- asprintf(&script, ". /lib/functions.sh\n. %s\n", pc->globbuf.gl_pathv[pc->cnt++]);
+ if (asprintf(&script, ". /lib/functions.sh\n. %s\n", pc->globbuf.gl_pathv[pc->cnt++]) == -1) {
+ pc->ret = ENOMEM;
+ return;
+ }
+
/* prepare for execve() */
exec_argv[0] = "/bin/sh";
exec_argv[1] = "-c";
@@ -302,7 +306,8 @@ static void add_subsystem(int nlen, char *newname)
struct hotplug_subsys *nh = calloc(1, sizeof(struct hotplug_subsys));
char *name;
- asprintf(&name, "%s%.*s", HOTPLUG_OBJECT_PREFIX, nlen, newname);
+ if (asprintf(&name, "%s%.*s", HOTPLUG_OBJECT_PREFIX, nlen, newname) == -1)
+ exit(ENOMEM);
/* prepare and add ubus object */
nh->ubus.name = name;