From 376f0387261df8b2c3d5b0718a98740b9732aa24 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 30 Jul 2015 22:16:47 +0200 Subject: [PATCH] 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 --- libs/luci-lib-nixio/src/address.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/luci-lib-nixio/src/address.c b/libs/luci-lib-nixio/src/address.c index 4fd557d6a7..8ab4fa89c9 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__ -- 2.30.2