From: Daniel Golle Date: Sat, 16 Oct 2021 23:29:08 +0000 (+0100) Subject: jail: netifd: fix error handling issue reported by coverity X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=d2a2eccbd145d246e3967aae0d75f20655426163;p=project%2Fprocd.git jail: netifd: fix error handling issue reported by coverity Check asprintf return value instead of checking for NULL-pointer. Coverity CID: 1492158 Unchecked return value Signed-off-by: Daniel Golle --- diff --git a/jail/netifd.c b/jail/netifd.c index 6096cfc..f6f2df6 100644 --- a/jail/netifd.c +++ b/jail/netifd.c @@ -425,14 +425,12 @@ int jail_network_start(struct ubus_context *new_ctx, char *new_jail_name, pid_t ns_pid = new_ns_pid; jail_name = new_jail_name; - asprintf(&ubus_sock_dir, "/var/containers/ubus-%s", jail_name); - if (!ubus_sock_dir) { + if (asprintf(&ubus_sock_dir, "/var/containers/ubus-%s", jail_name) == -1) { ret = ENOMEM; goto errout_dir; } - asprintf(&ubus_sock_path, "%s/ubus", ubus_sock_dir); - if (!ubus_sock_path) { + if (asprintf(&ubus_sock_path, "%s/ubus", ubus_sock_dir) == -1) { ret = ENOMEM; goto errout_path; }