Fix potential NULL pointer with DHCP plugin and hostname
authorMarcel Holtmann <marcel@holtmann.org>
Mon, 2 Aug 2010 16:02:43 +0000 (09:02 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Mon, 2 Aug 2010 16:02:43 +0000 (09:02 -0700)
plugins/dhcp.c

index b07a711..1e6b83d 100644 (file)
@@ -111,6 +111,7 @@ static int dhcp_request(struct connman_dhcp *dhcp)
 {
        GDHCPClient *dhcp_client;
        GDHCPClientError error;
+       const char *hostname;
        int index;
 
        DBG("dhcp %p", dhcp);
@@ -124,8 +125,9 @@ static int dhcp_request(struct connman_dhcp *dhcp)
        if (getenv("CONNMAN_DHCP_DEBUG"))
                g_dhcp_client_set_debug(dhcp_client, dhcp_debug, "DHCP");
 
-       g_dhcp_client_set_send(dhcp_client, G_DHCP_HOST_NAME,
-                               connman_utsname_get_hostname());
+       hostname = connman_utsname_get_hostname();
+       if (hostname != NULL)
+               g_dhcp_client_set_send(dhcp_client, G_DHCP_HOST_NAME, hostname);
 
        g_dhcp_client_set_request(dhcp_client, G_DHCP_HOST_NAME);
        g_dhcp_client_set_request(dhcp_client, G_DHCP_SUBNET);