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

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