From: Michael Tremer Date: Mon, 20 Oct 2025 14:23:02 +0000 (+0000) Subject: sources: hostapd: Zero-pad MAC addresses X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb029b03c461274a9ff42856c0189cf0fd189806;p=telemetry.git sources: hostapd: Zero-pad MAC addresses Signed-off-by: Michael Tremer --- diff --git a/src/daemon/sources/hostapd.c b/src/daemon/sources/hostapd.c index d5ab2e4..85c42a8 100644 --- a/src/daemon/sources/hostapd.c +++ b/src/daemon/sources/hostapd.c @@ -26,6 +26,7 @@ #include "../ctx.h" #include "../file.h" #include "../source.h" +#include "../string.h" #include "hostapd.h" typedef struct hostapd_station { @@ -80,17 +81,20 @@ static int ether_is_zero(const struct ether_addr* address) { static int hostapd_submit_station(td_ctx* ctx, hostapd_station* station) { char address[ETHER_MAX_LEN]; - char* p = NULL; + int r; // Skip if we don't have a MAC address if (ether_is_zero(&station->address)) return 0; // Format the address - p = ether_ntoa_r(&station->address, address); - if (!p) { - DEBUG(ctx, "Failed to format MAC address: %m\n"); - return -errno; + r = td_string_format(address, "%02x:%02x:%02x:%02x:%02x:%02x", + station->address.ether_addr_octet[0], station->address.ether_addr_octet[1], + station->address.ether_addr_octet[2], station->address.ether_addr_octet[3], + station->address.ether_addr_octet[4], station->address.ether_addr_octet[5]); + if (r < 0) { + DEBUG(ctx, "Failed to format MAC address: %s\n", strerror(-r)); + return r; } // Submit the station