Discussion:
[PATCH] supplicant.c: Fixed Potential Crash issue
(too old to reply)
Maneesh Jain
2015-10-05 09:01:22 UTC
Permalink
Signed-off-by: Maneesh Jain <***@samsung.com>
---
gsupplicant/supplicant.c | 6 ++++++
1 files changed, 6 insertions(+)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 98ca94b..9506f02
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2804,6 +2804,9 @@ static void signal_peer_found(const char *path, DBusMessageIter *iter)
g_hash_table_replace(peer_mapping, peer->path, interface);

property_data = dbus_malloc0(sizeof(struct peer_property_data));
+ if (!property_data)
+ return;
+
property_data->peer = peer;

dbus_message_iter_next(iter);
@@ -2861,6 +2864,9 @@ static void signal_peer_changed(const char *path, DBusMessageIter *iter)
}

property_data = dbus_malloc0(sizeof(struct peer_property_data));
+ if (!property_data)
+ return;
+
property_data->peer = peer;

supplicant_dbus_property_foreach(iter, peer_property, property_data);
--
1.9.1
Patrik Flykt
2015-10-08 06:39:14 UTC
Permalink
Hi,
Post by Maneesh Jain
---
gsupplicant/supplicant.c | 6 ++++++
1 files changed, 6 insertions(+)
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 98ca94b..9506f02
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -2804,6 +2804,9 @@ static void signal_peer_found(const char *path, DBusMessageIter *iter)
g_hash_table_replace(peer_mapping, peer->path, interface);
property_data = dbus_malloc0(sizeof(struct peer_property_data));
+ if (!property_data)
+ return;
+
NACK. With the above code there will be a peer object without any of its
associated data. Not a good thing. Please do the needed allocations
first, and if either fail, don't add a new peer.
Post by Maneesh Jain
property_data->peer = peer;
dbus_message_iter_next(iter);
@@ -2861,6 +2864,9 @@ static void signal_peer_changed(const char *path, DBusMessageIter *iter)
}
property_data = dbus_malloc0(sizeof(struct peer_property_data));
+ if (!property_data)
+ return;
+
Same here. This time the peer is not updated, though.
Post by Maneesh Jain
property_data->peer = peer;
supplicant_dbus_property_foreach(iter, peer_property, property_data);
Patrik

Loading...