From 506d5862768b3b26969de9daab3fa77b7cb1ab7d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 25 Feb 2012 22:42:39 +0100 Subject: [PATCH] port numbers: convert them to network order! When the config options ARES_OPT_UDP_PORT or ARES_OPT_TCP_PORT are used, make sure to convert them to network byte order! Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-02/0004.shtml --- ares_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ares_init.c b/ares_init.c index 252569f..ea2a978 100644 --- a/ares_init.c +++ b/ares_init.c @@ -434,9 +434,9 @@ static int init_by_options(ares_channel channel, if ((optmask & ARES_OPT_ROTATE) && channel->rotate == -1) channel->rotate = 1; if ((optmask & ARES_OPT_UDP_PORT) && channel->udp_port == -1) - channel->udp_port = options->udp_port; + channel->udp_port = htons(options->udp_port); if ((optmask & ARES_OPT_TCP_PORT) && channel->tcp_port == -1) - channel->tcp_port = options->tcp_port; + channel->tcp_port = htons(options->tcp_port); if ((optmask & ARES_OPT_SOCK_STATE_CB) && channel->sock_state_cb == NULL) { channel->sock_state_cb = options->sock_state_cb; -- 2.7.4