port numbers: convert them to network order!
authorDaniel Stenberg <daniel@haxx.se>
Sat, 25 Feb 2012 21:42:39 +0000 (22:42 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 16 Mar 2012 15:06:03 +0000 (16:06 +0100)
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

index 252569f..ea2a978 100644 (file)
@@ -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;