Blame SOURCES/0097-RH-fix-coverity-errors.patch

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