mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
util: fix byte order of port in virSocketAddrResolveService
The ports in the socket address structures returned by getaddrinfo() are in network byte order. Convert to host byte order before returning them. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Michael Chapman <mike@very.puzzling.org>
This commit is contained in:
parent
7d84ce059e
commit
425e5783f9
@ -265,12 +265,12 @@ int virSocketAddrResolveService(const char *service)
|
||||
if (tmp->ai_family == AF_INET) {
|
||||
struct sockaddr_in in;
|
||||
memcpy(&in, tmp->ai_addr, sizeof(in));
|
||||
port = in.sin_port;
|
||||
port = ntohs(in.sin_port);
|
||||
goto cleanup;
|
||||
} else if (tmp->ai_family == AF_INET6) {
|
||||
struct sockaddr_in6 in;
|
||||
memcpy(&in, tmp->ai_addr, sizeof(in));
|
||||
port = in.sin6_port;
|
||||
port = ntohs(in.sin6_port);
|
||||
goto cleanup;
|
||||
}
|
||||
tmp++;
|
||||
|
Loading…
Reference in New Issue
Block a user