GInetSocketAddress: fix the byte order of flowinfo and scope_id

The flowinfo and scope_id fields of struct sockaddr_in6 are in host
byte order, but the code previously assumed they were in network byte
order. Fix that.

This is an ABI-breaking change (since before you would have had to use
g_ntohl() and g_htonl() with them to get the correct values, and now
that would give the wrong values), but the previous behavior was
clearly wrong, and no one ever reported it, so it is likely that no
one was actually using it.

https://bugzilla.gnome.org/show_bug.cgi?id=684404
This commit is contained in:
Dan Winship
2012-12-12 16:00:26 +01:00
parent 0ea7abaed5
commit a60014f1b6
4 changed files with 12 additions and 6 deletions

View File

@@ -227,8 +227,8 @@ g_inet_socket_address_to_native (GSocketAddress *address,
memset (sock, 0, sizeof (*sock));
sock->sin6_family = AF_INET6;
sock->sin6_port = g_htons (addr->priv->port);
sock->sin6_flowinfo = g_htonl (addr->priv->flowinfo);
sock->sin6_scope_id = g_htonl (addr->priv->scope_id);
sock->sin6_flowinfo = addr->priv->flowinfo;
sock->sin6_scope_id = addr->priv->scope_id;
memcpy (&(sock->sin6_addr.s6_addr), g_inet_address_to_bytes (addr->priv->address), sizeof (sock->sin6_addr));
return TRUE;
}