From: Kenneth Heitke Date: Mon, 1 Apr 2019 18:15:55 +0000 (-0600) Subject: Fix possible NULL pointer dereferences X-Git-Tag: v1.8~14^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=cf184077deb08e76af6602c6d774e4f2cf1db95b;p=users%2Fsagi%2Fnvme-cli.git Fix possible NULL pointer dereferences --- diff --git a/argconfig.c b/argconfig.c index 984b3d05..55bef7f0 100644 --- a/argconfig.c +++ b/argconfig.c @@ -390,6 +390,8 @@ int argconfig_parse_subopt_string(char *string, char **options, } tmp = calloc(strlen(string) + 2, 1); + if (!tmp) + return 1; strcpy(tmp, string); toklen = strcspn(tmp, "="); diff --git a/nvme.c b/nvme.c index e88d1994..d8646620 100644 --- a/nvme.c +++ b/nvme.c @@ -1334,10 +1334,9 @@ static char *get_nvme_subsnqn(char *path) strerror(errno)); free(subsysnqn); subsysnqn = NULL; - } - - if (subsysnqn[strlen(subsysnqn) - 1] == '\n') + } else if (subsysnqn[strlen(subsysnqn) - 1] == '\n') { subsysnqn[strlen(subsysnqn) - 1] = '\0'; + } close_fd: close(fd);