From: Daniel Golle Date: Sun, 20 Feb 2022 12:43:36 +0000 (+0000) Subject: uxc: fix potential NULL-pointer dereference X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=5c5e63f89ab3c0eb93e8733c196bb9b27e663c90;p=project%2Fprocd.git uxc: fix potential NULL-pointer dereference Check for NULL returned by strrchr() and return error in that case. It should not be reachable as the string should always contain a '/' character, but follow best practices anyway. Coverity CID: 1500356 Dereference null return value Signed-off-by: Daniel Golle --- diff --git a/uxc.c b/uxc.c index 332b91d..c15b4bc 100644 --- a/uxc.c +++ b/uxc.c @@ -1032,6 +1032,9 @@ static int uxc_set(char *name, char *path, signed char autostart, char *pidfile, char *t1, *t2; t1 = strdup(cfname); t2 = strrchr(t1, '/'); + if (!t2) + return -EINVAL; + *t2 = '\0'; if (asprintf(&t2, "%s/settings", t1) == -1)