[PATCH] ipconfig: Do not pass a NULL pointer to D-Bus

2014-08-29 Thread Hannu Mallat
connman_inet_ifname() may return a NULL pointer e.g. if the interface
does not exist in the kernel anymore but connman isn't yet aware of
that. Passing a NULL pointer to D-Bus may result in an abort, so check
the return value.
---
 src/ipconfig.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index b7e4f94..fa4c0d6 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -2166,9 +2166,11 @@ void __connman_ipconfig_append_ethernet(struct 
connman_ipconfig *ipconfig,
 
if (ipconfig->index >= 0) {
char *ifname = connman_inet_ifname(ipconfig->index);
-   connman_dbus_dict_append_basic(iter, "Interface",
-   DBUS_TYPE_STRING, &ifname);
-   g_free(ifname);
+   if (ifname) {
+   connman_dbus_dict_append_basic(iter, "Interface",
+   DBUS_TYPE_STRING, &ifname);
+   g_free(ifname);
+   }
}
 
if (ipdevice->address)
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] ipconfig: Do not pass a NULL pointer to D-Bus

2014-09-02 Thread Patrik Flykt
On Fri, 2014-08-29 at 10:00 +0300, Hannu Mallat wrote:
> connman_inet_ifname() may return a NULL pointer e.g. if the interface
> does not exist in the kernel anymore but connman isn't yet aware of
> that. Passing a NULL pointer to D-Bus may result in an abort, so check
> the return value.

Applied, thanks!

Patrik

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman