From 1c94ea2b5c88a5b3bd28b3f34eb22260af26f324 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= <vladimir.cunat@nic.cz>
Date: Tue, 16 Apr 2019 12:52:16 +0200
Subject: [PATCH] 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.
---
 daemon/bindings/net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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");
 
-- 
GitLab