From: Vladimír Čunát Date: Tue, 16 Apr 2019 10:52:16 +0000 (+0200) Subject: lua net.interfaces(): fix mac addresses X-Git-Tag: v4.0.0~5^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c94ea2b5c88a5b3bd28b3f34eb22260af26f324;p=thirdparty%2Fknot-resolver.git lua net.interfaces(): fix mac addresses Only the first byte was being shown since 3ab77332. I can't see at all why this part was changed; the buffer is (and was) way overlong for this, so writing one zero byte just after the end is OK. --- diff --git a/daemon/bindings/net.c b/daemon/bindings/net.c index 0b22ffcb6..144f8b47f 100644 --- a/daemon/bindings/net.c +++ b/daemon/bindings/net.c @@ -240,11 +240,11 @@ static int net_interfaces(lua_State *L) /* Hardware address. */ char *p = buf; - memset(buf, 0, sizeof(buf)); - for (unsigned k = 0; k < sizeof(iface.phys_addr); ++k) { - sprintf(p, "%s%.2x", k > 0 ? ":" : "", iface.phys_addr[k] & 0xff); + for (int k = 0; k < sizeof(iface.phys_addr); ++k) { + sprintf(p, "%.2x:", (uint8_t)iface.phys_addr[k]); p += 3; } + p[-1] = '\0'; lua_pushstring(L, buf); lua_setfield(L, -2, "mac");