[PATCH] sa-confdb: fix crash due to incorrect malloc size

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

 



From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx>

with recent changes, confdb and saconfdb were allocating two different
sizes for the same results. While on x86_64 this was masked nicely,
on i686 it causes crashes.

Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx>
---
 lib/sa-confdb.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/sa-confdb.c b/lib/sa-confdb.c
index 9a11418..7a8fabf 100644
--- a/lib/sa-confdb.c
+++ b/lib/sa-confdb.c
@@ -263,7 +263,7 @@ int confdb_sa_key_get_typed (
 				    &kvalue, value_len, (objdb_value_types_t*)type);
 	if (!res) {
 		if (!*value) {
-			*value = malloc(*value_len);
+			*value = malloc(*value_len + 1);
 			if (!*value) {
 				res = CS_ERR_NO_MEMORY;
 			}
@@ -443,7 +443,7 @@ int confdb_sa_key_iter_typed (
 		memcpy(key_name, kname, key_name_len);
 		key_name[key_name_len] = '\0';
 		if (!*value) {
-			*value = malloc(*value_len);
+			*value = malloc(*value_len + 1);
 			if (!*value) {
 				res = CS_ERR_NO_MEMORY;
 			}
-- 
1.7.7.6

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux