]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Check strdup return value
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 10 Sep 2024 18:06:11 +0000 (20:06 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 17 Sep 2024 03:40:26 +0000 (22:40 -0500)
If strdup fails, return error.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/130
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index 90509d329117ebe77a00e90b9209ac62b9474a95..0326a5f0b6aac1760ee5687c2a229d199ff23352 100644 (file)
@@ -1034,6 +1034,10 @@ static int depmod_module_add(struct depmod *depmod, struct kmod_module *kmod)
        array_init(&mod->deps, 4);
 
        mod->path = strdup(kmod_module_get_path(kmod));
+       if (mod->path == NULL) {
+               free(mod);
+               return -ENOMEM;
+       }
        lastslash = strrchr(mod->path, '/');
        mod->baselen = lastslash - mod->path;
        if (strncmp(mod->path, cfg->dirname, cfg->dirnamelen) == 0 &&