Skip to contentSkip to conversation

master - format1: check for lvm1_system_id

PATCH Zdenek Kabelac 1 participant 1 message May 8, 2015

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=950a21d58adc581f921847f5c356a45f4f9cce94
Commit:        950a21d58adc581f921847f5c356a45f4f9cce94
Parent:        05934d2538b76134fe4a5f4ddd7954ff32620b50
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu May 7 13:09:43 2015 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri May 8 15:15:10 2015 +0200

format1: check for lvm1_system_id

As in the code above in this function continue to check for lvm1_system_id pointer existance before dereferencing it (Coverity).

---
 lib/format1/import-export.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
lib/format1/import-export.c +2 -2
index 9b387e2..72f6946 100644
@@ -180,7 +180,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused
 	}
 
 	/* Is VG being imported? */
-	if (vg && !vg_is_exported(vg) && *vg->lvm1_system_id &&
+	if (vg && !vg_is_exported(vg) && vg->lvm1_system_id && *vg->lvm1_system_id &&
 	    !strncmp(vg->lvm1_system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
 		if (!generate_lvm1_system_id(cmd, (char *)pvd->system_id, IMPORTED_TAG))
 			return_0;
@@ -192,7 +192,7 @@ int export_pv(struct cmd_context *cmd, struct dm_pool *mem __attribute__((unused
 			return_0;
 
 	/* Update internal system_id if we changed it */
-	if (vg &&
+	if (vg && vg->lvm1_system_id &&
 	    (!*vg->lvm1_system_id ||
 	     strncmp(vg->lvm1_system_id, (char *)pvd->system_id, sizeof(pvd->system_id))))
 		    strncpy(vg->lvm1_system_id, (char *)pvd->system_id, NAME_LEN);