From 4bdeab805fcb0d8fe16af04eb40a6c046d97941c Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 28 Apr 2017 22:51:36 +0100 Subject: [PATCH] util.c: Don't byte-swap IPv4 addresses, even if we don't have IPv6. The `string_item_to_ipaddr' function returns addresses as a single integer in host byte order. But this isn't what's wanted for setting up `struct sockaddr_in', for example. The function `adns_text2addr' does the right thing. I think this has always been wrong for setting up UDP sockets: before the introduction of `string_item_to_iaddr', `udp_apply' would call `string_item_to_ipaddr' directly, and neglected to swap the bytes. Signed-off-by: Mark Wooding --- util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util.c b/util.c index c601f0f..d12db66 100644 --- a/util.c +++ b/util.c @@ -521,7 +521,7 @@ void string_item_to_iaddr(const item_t *item, uint16_t port, union iaddr *ia, #ifndef CONFIG_IPV6 ia->sin.sin_family=AF_INET; - ia->sin.sin_addr.s_addr=string_item_to_ipaddr(item,desc); + ia->sin.sin_addr.s_addr=htonl(string_item_to_ipaddr(item,desc)); ia->sin.sin_port=htons(port); #else /* CONFIG_IPV6 => we have adns_text2addr */ -- 2.11.0