From 60d340b3878dbba73eb9070c086425fd6893a3c6 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 1 Dec 2010 12:22:49 +0000 Subject: [PATCH] Test lv_name is not NULL Patch adds extra check for lv_name not being NULL. Test avoids unneeded strlen call for this case. Otherwise there is no functional change as test would fail on size_t comparation even for NULL lv_name (thus there is no risk of NULL dereference when taking 'true' if branch. --- tools/toollib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/toollib.c b/tools/toollib.c index f6ba45be0..9be993629 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -331,7 +331,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv, tags_arg = NULL; dm_list_init(&lvnames); break; - } else if (!strncmp(vg_name, vgname, strlen(vgname)) && + } else if (!strncmp(vg_name, vgname, strlen(vgname)) && lv_name && strlen(vgname) == (size_t) (lv_name - vg_name)) { if (!str_list_add(cmd->mem, &lvnames, dm_pool_strdup(cmd->mem, -- 2.43.5