summaryrefslogtreecommitdiffhomepage
path: root/libs/luci-lib-nixio
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-07-30 22:16:47 +0200
committerJo-Philipp Wich <jow@openwrt.org>2015-07-30 22:38:36 +0200
commit376f0387261df8b2c3d5b0718a98740b9732aa24 (patch)
tree0b1ed95550b280115194a892088b5a4caaa9708c /libs/luci-lib-nixio
parent69ecfff002452c8ac220c4fe83156c4dfa985fa0 (diff)
luci-lib-nixio: pass exact sockaddr length to getnameinfo()
Musl libc requires the length parameter of getnameinfo() to be exactly `sizeof(struct sockaddr_in)` or `sizeof(struct sockaddr_in6)`, depending on the passed sockaddr family. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'libs/luci-lib-nixio')
-rw-r--r--libs/luci-lib-nixio/src/address.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libs/luci-lib-nixio/src/address.c b/libs/luci-lib-nixio/src/address.c
index 4fd557d6a..8ab4fa89c 100644
--- a/libs/luci-lib-nixio/src/address.c
+++ b/libs/luci-lib-nixio/src/address.c
@@ -331,7 +331,9 @@ static int nixio_getnameinfo(lua_State *L) {
nixio__addr_write(&addr, (struct sockaddr *)&saddr);
- int res = getnameinfo((struct sockaddr *)&saddr, sizeof(saddr),
+ int res = getnameinfo((struct sockaddr *)&saddr,
+ (saddr.ss_family == AF_INET)
+ ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6),
host, sizeof(host), NULL, 0, NI_NAMEREQD);
#ifdef __linux__