Просмотр исходного кода

sa-confdb: fix crash due to incorrect malloc size

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@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Fabio M. Di Nitto 13 лет назад
Родитель
Сommit
0a85b888b0
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      lib/sa-confdb.c

+ 2 - 2
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;
 			}