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

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



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 redhat com>
---
 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


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