diff options
| author | Daniel Golle | 2022-02-20 12:43:36 +0000 |
|---|---|---|
| committer | Daniel Golle | 2022-04-13 02:58:39 +0000 |
| commit | 5c5e63f89ab3c0eb93e8733c196bb9b27e663c90 (patch) | |
| tree | a7f5e96c32fb447b318a30f48e0d051a27e8d82a | |
| parent | 6343c3a8b967abd23c9f858341a5d46afab0f36a (diff) | |
| download | procd-5c5e63f89ab3c0eb93e8733c196bb9b27e663c90.tar.gz | |
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 <daniel@makrotopia.org>
| -rw-r--r-- | uxc.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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) |