From dc99c4dc21277ab289977940b63a5464591638a1 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Thu, 12 Apr 2012 15:27:52 +0000 Subject: [PATCH] - wrong NBO conversion: port is always zero! --- src/util/strings.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/strings.c b/src/util/strings.c index 54dee15f8..e686f60f0 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -1017,7 +1017,7 @@ GNUNET_STRINGS_to_address_ipv6 (const char *zt_addr, ret = inet_pton (AF_INET6, zt_addr, &r_buf->sin6_addr); if (ret <= 0) return GNUNET_SYSERR; - r_buf->sin6_port = htonl (port); + r_buf->sin6_port = htons (port); r_buf->sin6_family = AF_INET6; return GNUNET_OK; } @@ -1037,7 +1037,7 @@ GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, uint16_t addrlen, struct sockaddr_in *r_buf) { unsigned int temps[5]; - unsigned int port; + int port; int cnt; if (addrlen < 9) @@ -1053,8 +1053,10 @@ GNUNET_STRINGS_to_address_ipv4 (const char *zt_addr, uint16_t addrlen, if (port > 65535) return GNUNET_SYSERR; + + r_buf->sin_family = AF_INET; - r_buf->sin_port = htonl (port); + r_buf->sin_port = htons (port); r_buf->sin_addr.s_addr = htonl ((temps[0] << 24) + (temps[1] << 16) + (temps[2] << 8) + temps[3]); return GNUNET_OK; -- 2.25.1