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

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