uxc: fix potential NULL-pointer dereference
[project/procd.git] / uxc.c
diff --git a/uxc.c b/uxc.c
index 332b91d268e56bd9cd383f9c9f995a8c7c1c4c0d..c15b4bc42cbeb93b0262edc741b4d025fcf1a197 100644 (file)
--- 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)