summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-08-02 16:02:43 (GMT)
committerMarcel Holtmann <marcel@holtmann.org>2010-08-02 16:02:43 (GMT)
commit4fc2968ea3c3237bbb78bcd78391980b0727f06a (patch)
tree61434f0aa7655b9c56ab5fb463a27b6619b4ec6c
parent335fb71873349127a830f37e5c71817bba801460 (diff)
downloadconnman-4fc2968ea3c3237bbb78bcd78391980b0727f06a.zip
connman-4fc2968ea3c3237bbb78bcd78391980b0727f06a.tar.gz
connman-4fc2968ea3c3237bbb78bcd78391980b0727f06a.tar.bz2
Fix potential NULL pointer with DHCP plugin and hostname
-rw-r--r--plugins/dhcp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/dhcp.c b/plugins/dhcp.c
index b07a711..1e6b83d 100644
--- a/plugins/dhcp.c
+++ b/plugins/dhcp.c
@@ -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);