Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
service: Handle NULL pointer in __connman_service_set_{domain|host}name
516af0f ("service: Sanitize input for hostname and domainname")
address the shutdown path:

connmand[12534]: ++++++++ backtrace ++++++++
connmand[12534]: #0  0x7fefba7195c0 in /lib64/libc.so.6
connmand[12534]: #1  0x7fefbab8caa4 in /lib64/libglib-2.0.so.0
connmand[12534]: #2  0x44c600 in __connman_service_set_domainname() at src/service.c:2664
connmand[12534]: #3  0x462d16 in apply_dhcp_invalidate_on_network() at src/dhcp.c:110
connmand[12534]: #4  0x463c87 in dhcp_free() at src/dhcp.c:70
connmand[12534]: #5  0x442bd8 in set_disconnected() at src/network.c:1009
connmand[12534]: #6  0x442e10 in network_remove() at src/network.c:1120
connmand[12534]: #7  0x442e77 in connman_network_driver_unregister() at src/network.c:1211
connmand[12534]: #8  0x41cf88 in ethernet_exit() at plugins/ethernet.c:462
connmand[12534]: #9  0x43f1d9 in __connman_plugin_cleanup() at src/plugin.c:202
connmand[12534]: #10 0x4113f4 in main() at src/main.c:874
connmand[12534]: #11 0x7fefba705413 in /lib64/libc.so.6
  • Loading branch information
igaw authored and LaakkonenJussi committed Mar 12, 2021
1 parent 6db7b97 commit 97a4dd8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions connman/src/service.c
Expand Up @@ -3651,7 +3651,10 @@ void __connman_service_set_hostname(struct connman_service *service,
return;

g_free(service->hostname);
service->hostname = g_strdup(hostname);
service->hostname = NULL;

if (hostname && g_str_is_ascii(hostname))
service->hostname = g_strdup(hostname);
}

const char *__connman_service_get_hostname(struct connman_service *service)
Expand All @@ -3669,7 +3672,10 @@ void __connman_service_set_domainname(struct connman_service *service,
return;

g_free(service->domainname);
service->domainname = g_strdup(domainname);
service->domainname = NULL;

if (domainname && g_str_is_ascii(domainname))
service->domainname = g_strdup(domainname);

domain_changed(service);
}
Expand Down

0 comments on commit 97a4dd8

Please sign in to comment.