Mon, 21 Dec 2020 20:23:47 -0600
Replace inet_pton by gio.
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/303/
| libpurple/protocols/bonjour/bonjour_ft.c | file | annotate | diff | comparison | revisions | |
| libpurple/protocols/bonjour/xmpp.c | file | annotate | diff | comparison | revisions |
--- a/libpurple/protocols/bonjour/bonjour_ft.c Sun Dec 20 05:30:08 2020 -0600 +++ b/libpurple/protocols/bonjour/bonjour_ft.c Mon Dec 21 20:23:47 2020 -0600 @@ -592,14 +592,20 @@ PurpleBuddy *pb) { PurpleXmlNode *new_streamhost = NULL; - struct in6_addr in6_addr; + GInetAddress *addr; BonjourBuddy *bb; GSList *ip_elem; - if (inet_pton(AF_INET6, host, &in6_addr) != 1 || - !IN6_IS_ADDR_LINKLOCAL(&in6_addr) || + addr = g_inet_address_new_from_string(host); + if (addr == NULL || + g_inet_address_get_family(addr) != G_SOCKET_FAMILY_IPV6 || + !g_inet_address_get_is_link_local(addr) || strchr(host, '%')) + { + g_clear_object(&addr); return FALSE; + } + g_clear_object(&addr); bb = purple_buddy_get_protocol_data(pb);
--- a/libpurple/protocols/bonjour/xmpp.c Sun Dec 20 05:30:08 2020 -0600 +++ b/libpurple/protocols/bonjour/xmpp.c Mon Dec 21 20:23:47 2020 -0600 @@ -1367,15 +1367,21 @@ void append_iface_if_linklocal(char *ip, guint32 interface_param) { - struct in6_addr in6_addr; + GInetAddress *addr; int len_remain = INET6_ADDRSTRLEN - strlen(ip); if (len_remain <= 1) return; - if (inet_pton(AF_INET6, ip, &in6_addr) != 1 || - !IN6_IS_ADDR_LINKLOCAL(&in6_addr)) + addr = g_inet_address_new_from_string(ip); + if (addr == NULL || + g_inet_address_get_family(addr) != G_SOCKET_FAMILY_IPV6 || + !g_inet_address_get_is_link_local(addr)) + { + g_clear_object(&addr); return; + } + g_clear_object(&addr); g_snprintf(ip + strlen(ip), len_remain, "%%%d", interface_param); }