From 56561f1b5850888c9266b1155d4ac6d352e791c4 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 28 Mar 2018 11:23:17 -0400 Subject: [PATCH] Don't write trailing colon when populating MAC string --- grub-core/net/net.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index a6566bd..f3f964e 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -797,11 +797,18 @@ grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str) return; } maxstr = addr->len * grub_strlen ("XX:"); - for (ptr = str, i = 0; i < addr->len; i++) + if (addr->len == 0) + { + return; + } + + for (ptr = str, i = 0; i < (addr->len - 1); i++) { ptr += grub_snprintf (ptr, maxstr - (ptr - str), "%02x:", addr->mac[i] & 0xff); } + ptr += grub_snprintf (ptr, maxstr - (ptr - str), + "%02x", addr->mac[i] & 0xff); } int -- 2.7.4