[PATCH 02/12] Return the correct size buffer in set_value()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When multipath was mallocing the buffer in set_value, it was using
sizeof(char *), instead of sizeof(char), so it was allocating a buffer
big enough for an array of pointers instead of characters.

Signed-off-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>
---
 libmultipath/parser.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libmultipath/parser.c b/libmultipath/parser.c
index 526c45b..0d4c870 100644
--- a/libmultipath/parser.c
+++ b/libmultipath/parser.c
@@ -408,11 +408,11 @@ set_value(vector strvec)
 			len += strlen(str);
 			if (!alloc)
 				alloc =
-				    (char *) MALLOC(sizeof (char *) *
+				    (char *) MALLOC(sizeof (char) *
 						    (len + 1));
 			else {
 				alloc =
-				    REALLOC(alloc, sizeof (char *) * (len + 1));
+				    REALLOC(alloc, sizeof (char) * (len + 1));
 				tmp = VECTOR_SLOT(strvec, i-1);
 				if (alloc && *str != '"' && *tmp != '"')
 					strncat(alloc, " ", 1);
@@ -422,7 +422,7 @@ set_value(vector strvec)
 				strncat(alloc, str, strlen(str));
 		}
 	} else {
-		alloc = MALLOC(sizeof (char *) * (size + 1));
+		alloc = MALLOC(sizeof (char) * (size + 1));
 		if (alloc)
 			memcpy(alloc, str, size);
 	}
-- 
1.8.3.1

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux