From: Matthias Wachs Date: Thu, 12 Apr 2012 15:27:52 +0000 (+0000) Subject: - wrong NBO conversion: port is always zero! X-Git-Tag: initial-import-from-subversion-38251~13927 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=dc99c4dc21277ab289977940b63a5464591638a1;p=oweals%2Fgnunet.git - wrong NBO conversion: port is always zero! --- 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;