Skip to contentSkip to conversation

LVM2/tools dmsetup.c

PATCH [email protected] 1 participant 1 message Feb 15, 2012

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha at sourceware.org 2012-02-15 14:21:00

Modified files:
tools : dmsetup.c

Log message:
Fix segfault in dmsetup when using table specification with --table.

Segfault introduced with the patch that added dm_free(_table) at the end of dmsetup (in this release).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dmsetup.c.diff?cvsroot=lvm2&r1=1.179&r2=1.180

tools/dmsetup.c +5 -1
@@ -3654,7 +3654,11 @@
 			_switches[SHOWKEYS_ARG]++;
 		if (ind == TABLE_ARG) {
 			_switches[TABLE_ARG]++;
-			_table = optarg;
+			if (!(_table = dm_malloc(strlen(optarg + 1)))) {
+				log_error("Could not allocate memory for table string.");
+				return 0;
+			}
+			strcpy(_table, optarg);
 		}
 		if (ind == TREE_ARG)
 			_switches[TREE_ARG]++;