f20720
---
f20720
 kpartx/devmapper.c                       |    3 ++-
f20720
 libmultipath/alias.c                     |    1 +
f20720
 libmultipath/blacklist.c                 |    7 +++++++
f20720
 libmultipath/prioritizers/iet.c          |    2 ++
f20720
 libmultipath/prioritizers/weightedpath.c |    5 ++++-
f20720
 libmultipath/regex.c                     |    5 ++++-
f20720
 libmultipath/sysfs.c                     |    3 ++-
f20720
 libmultipath/util.c                      |    2 +-
f20720
 8 files changed, 23 insertions(+), 5 deletions(-)
f20720
f20720
Index: multipath-tools-130222/kpartx/devmapper.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/kpartx/devmapper.c
f20720
+++ multipath-tools-130222/kpartx/devmapper.c
f20720
@@ -132,8 +132,9 @@ dm_addmap (int task, const char *name, c
f20720
 		goto addout;
f20720
 	r = dm_task_run (dmt);
f20720
 
f20720
-	addout:
f20720
+addout:
f20720
 	dm_task_destroy (dmt);
f20720
+	free(prefixed_uuid);
f20720
 
f20720
 	return r;
f20720
 }
f20720
Index: multipath-tools-130222/libmultipath/alias.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/alias.c
f20720
+++ multipath-tools-130222/libmultipath/alias.c
f20720
@@ -328,6 +328,7 @@ get_user_friendly_alias(char *wwid, char
f20720
 	if (fflush(f) != 0) {
f20720
 		condlog(0, "cannot fflush bindings file stream : %s",
f20720
 			strerror(errno));
f20720
+		free(alias);
f20720
 		fclose(f);
f20720
 		return NULL;
f20720
 	}
f20720
Index: multipath-tools-130222/libmultipath/blacklist.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/blacklist.c
f20720
+++ multipath-tools-130222/libmultipath/blacklist.c
f20720
@@ -79,6 +79,8 @@ set_ble_device (vector blist, char * ven
f20720
 		if (regcomp(&ble->vendor_reg, vendor,
f20720
 			    REG_EXTENDED|REG_NOSUB)) {
f20720
 			FREE(vendor);
f20720
+			if (product)
f20720
+				FREE(product);
f20720
 			return 1;
f20720
 		}
f20720
 		ble->vendor = vendor;
f20720
@@ -87,6 +89,10 @@ set_ble_device (vector blist, char * ven
f20720
 		if (regcomp(&ble->product_reg, product,
f20720
 			    REG_EXTENDED|REG_NOSUB)) {
f20720
 			FREE(product);
f20720
+			if (vendor) {
f20720
+				ble->vendor = NULL;
f20720
+				FREE(vendor);
f20720
+			}
f20720
 			return 1;
f20720
 		}
f20720
 		ble->product = product;
f20720
@@ -189,6 +195,7 @@ setup_default_blist (struct config * con
f20720
 					   STRDUP(hwe->bl_product),
f20720
 					   ORIGIN_DEFAULT)) {
f20720
 				FREE(ble);
f20720
+				vector_del_slot(conf->blist_device, VECTOR_SIZE(conf->blist_device) - 1);
f20720
 				return 1;
f20720
 			}
f20720
 		}
f20720
Index: multipath-tools-130222/libmultipath/prioritizers/iet.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/prioritizers/iet.c
f20720
+++ multipath-tools-130222/libmultipath/prioritizers/iet.c
f20720
@@ -109,6 +109,7 @@ int iet_prio(const char *dev, char * arg
f20720
 			ssize_t nchars = readlink(path, buffer, sizeof(buffer)-1);
f20720
 			if (nchars != -1) {
f20720
 				char *device;
f20720
+				buffer[nchars] = '\0';
f20720
 				device = find_regex(buffer,"(sd[a-z]+)");
f20720
 				// if device parsed is the right one
f20720
 				if (device!=NULL && strncmp(device, dev, strlen(device)) == 0) {
f20720
@@ -118,6 +119,7 @@ int iet_prio(const char *dev, char * arg
f20720
 					if (ip!=NULL && strncmp(ip, preferredip, strlen(ip)) == 0) {
f20720
 						// high prio
f20720
 						free(ip);
f20720
+						free(device);
f20720
 						closedir(dir_p);
f20720
 						return 20;
f20720
 					}
f20720
Index: multipath-tools-130222/libmultipath/prioritizers/weightedpath.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/prioritizers/weightedpath.c
f20720
+++ multipath-tools-130222/libmultipath/prioritizers/weightedpath.c
f20720
@@ -61,8 +61,10 @@ int prio_path_weight(struct path *pp, ch
f20720
 	regex = get_next_string(&temp, split_char);
f20720
 
f20720
 	/* Return default priority if the argument is not parseable */
f20720
-	if (!regex)
f20720
+	if (!regex) {
f20720
+		FREE(arg);
f20720
 		return priority;
f20720
+	}
f20720
 
f20720
 	if (!strcmp(regex, HBTL)) {
f20720
 		sprintf(path, "%d:%d:%d:%d", pp->sg_id.host_no,
f20720
@@ -72,6 +74,7 @@ int prio_path_weight(struct path *pp, ch
f20720
 	} else {
f20720
 		condlog(0, "%s: %s - Invalid arguments", pp->dev,
f20720
 			pp->prio.name);
f20720
+		FREE(arg);
f20720
 		return priority;
f20720
 	}
f20720
 
f20720
Index: multipath-tools-130222/libmultipath/regex.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/regex.c
f20720
+++ multipath-tools-130222/libmultipath/regex.c
f20720
@@ -3936,8 +3936,11 @@ int eflags;
f20720
 		regs.num_regs = nmatch;
f20720
 		regs.start = TALLOC(nmatch, regoff_t);
f20720
 		regs.end = TALLOC(nmatch, regoff_t);
f20720
-		if (regs.start == NULL || regs.end == NULL)
f20720
+		if (regs.start == NULL || regs.end == NULL) {
f20720
+			free(regs.start);
f20720
+			free(regs.end);
f20720
 			return (int) REG_NOMATCH;
f20720
+		}
f20720
 	}
f20720
 
f20720
 	/* Perform the searching operation.  */
f20720
Index: multipath-tools-130222/libmultipath/sysfs.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/sysfs.c
f20720
+++ multipath-tools-130222/libmultipath/sysfs.c
f20720
@@ -88,7 +88,8 @@ ssize_t sysfs_attr_get_value(struct udev
f20720
 	} else if (size == value_len) {
f20720
 		condlog(4, "overflow while reading from %s", devpath);
f20720
 		size = 0;
f20720
-	}
f20720
+	} else
f20720
+		value[size] = '\0';
f20720
 
f20720
 	close(fd);
f20720
 	return size;
f20720
Index: multipath-tools-130222/libmultipath/util.c
f20720
===================================================================
f20720
--- multipath-tools-130222.orig/libmultipath/util.c
f20720
+++ multipath-tools-130222/libmultipath/util.c
f20720
@@ -175,7 +175,7 @@ devt2devname (char *devname, int devname
f20720
 		sprintf(block_path,"/sys/dev/block/%u:%u", major, minor);
f20720
 		if (lstat(block_path, &statbuf) == 0) {
f20720
 			if (S_ISLNK(statbuf.st_mode) &&
f20720
-			    readlink(block_path, dev, FILE_NAME_SIZE) > 0) {
f20720
+			    readlink(block_path, dev, FILE_NAME_SIZE-1) > 0) {
f20720
 				char *p = strrchr(dev, '/');
f20720
 
f20720
 				if (!p) {