GNOME Bugzilla – Bug 656406
Wrong use of inet_netof leeds to dropped ssdp packages
Last modified: 2019-02-22 09:29:40 UTC
In gssd-client.c Func socket_source_cb (GSSDPSocketSource *socket_source, GSSDPClient *client) Line 900 is inet_netof used to determine the origin of the ssdp-packages. This will NOT work if you have two Users from e.g. 192.168.1.2 and 192.168.2.2 (netmask (255.255.0.0) cause inet_netof do NOT use the current netmask to determine the network part of these IPs. It only looks on the first octet (192). For IPv4 (ip1 & netmask) == (ip2 & netmask) should be evaluated. IPv6 ma be different.
Aaah, so this is why GUPnP doesn't work correctly in the office. Note that in recent GSSDP releases this code has been changed a lot, but the relevant check is still there at line 948.
I guess as this isn't as easy as it appears, this check should be implemented in GSocketAddress.
Maybe GInetSocketAddress, but You have already the network part of "our_addr" (see get_host_ip(...)). So, one should also store the ifa_netmask in privat->netmask (near line 1200 and 1209). Then we have to check (in socket_source_cb) without respect to IPv6: if ((addr.sin_addr & client->privat->netmask) != (our_addr.s_addr & client->privat->netmask)) goto out; The recv_network and our_network vars can be dropped. For me, that seems better than the existing code.
Created attachment 231526 [details] [review] Drop use of inet_netof This is just wrong in times of CIDR. Much appreciated if someone with a setup like that could test it.
Attachment 231526 [details] pushed as 48f5d5b - Drop use of inet_netof
Commited with slight merge issue fixes