From d2a2eccbd145d246e3967aae0d75f20655426163 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 17 Oct 2021 00:29:08 +0100 Subject: [PATCH] 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 --- jail/netifd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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; } -- 2.30.2