summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Smetana <tsmetana@redhat.com>2013-09-03 08:43:33 +0200
committerTomas Smetana <tsmetana@redhat.com>2013-09-03 08:43:33 +0200
commitd1d12708db81b8789a84b7a323f4244ec977ab1f (patch)
treea290402a2effe40f172fc73f3cd65f9193823f23
parent75cfd0c7003b6354c859d7e28e7d8eb8cb4cb4a2 (diff)
downloadopenlmi-providers-d1d12708db81b8789a84b7a323f4244ec977ab1f.tar.gz
openlmi-providers-d1d12708db81b8789a84b7a323f4244ec977ab1f.tar.xz
openlmi-providers-d1d12708db81b8789a84b7a323f4244ec977ab1f.zip
Realmd: check for possible NULL dereferences
-rw-r--r--src/realmd/rdcp_dbus.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/realmd/rdcp_dbus.c b/src/realmd/rdcp_dbus.c
index 75ee439..3df6803 100644
--- a/src/realmd/rdcp_dbus.c
+++ b/src/realmd/rdcp_dbus.c
@@ -181,6 +181,9 @@ dbus_message_print_byte_array(GString *string, DBusMessageIter *iter, int depth)
dbus_bool_t all_ascii = TRUE;
int current_type;
+ if (!bytes)
+ return;
+
while ((current_type = dbus_message_iter_get_arg_type (iter)) != DBUS_TYPE_INVALID) {
unsigned char val;
@@ -192,8 +195,12 @@ dbus_message_print_byte_array(GString *string, DBusMessageIter *iter, int depth)
all_ascii = FALSE;
if (len == max) {
+ unsigned char *tmp_bytes;
+
max *= 2;
- bytes = realloc(bytes, max + 1);
+ if (!(tmp_bytes = realloc(bytes, max + 1)))
+ goto fail;
+ bytes = tmp_bytes;
}
dbus_message_iter_next (iter);
@@ -206,6 +213,7 @@ dbus_message_print_byte_array(GString *string, DBusMessageIter *iter, int depth)
dbus_message_print_hex(string, bytes, len, depth);
}
+fail:
free (bytes);
}