From cc276263a3d9512cfbd9f743fde837fce3db511e Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 14 Oct 2014 09:12:56 +0200 Subject: [PATCH] url: fix port type to int (ports above 32766), use AI_NUMERICSERV in tcp and udp, fixes #2369 --- src/tcp.c | 2 +- src/udp.c | 2 +- src/url.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tcp.c b/src/tcp.c index 5cfc0a63..dc5d1823 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -647,7 +647,7 @@ tcp_server_create snprintf(port_buf, 6, "%d", port); memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_flags = AI_PASSIVE; + hints.ai_flags = AI_PASSIVE | AI_NUMERICSERV; if (bindaddr != NULL) hints.ai_flags |= AI_NUMERICHOST; hints.ai_family = AF_UNSPEC; diff --git a/src/udp.c b/src/udp.c index b01f114f..f18d23f0 100644 --- a/src/udp.c +++ b/src/udp.c @@ -48,7 +48,7 @@ udp_resolve( udp_connection_t *uc, int receiver ) snprintf(port_buf, 6, "%d", uc->port); memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_flags = receiver ? AI_PASSIVE : 0; + hints.ai_flags = (receiver ? AI_PASSIVE : 0) | AI_NUMERICSERV; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; diff --git a/src/url.h b/src/url.h index 4d7da6f3..5c9b632a 100644 --- a/src/url.h +++ b/src/url.h @@ -29,7 +29,7 @@ typedef struct url char *user; char *pass; char *host; - short port; + int port; char *path; char *query; char *frag;