|
|
d41074 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
d41074 |
From: Mark Salter <msalter@redhat.com>
|
|
|
d41074 |
Date: Tue, 22 Aug 2017 12:21:12 -0400
|
|
|
d41074 |
Subject: [PATCH] Fix grub_net_hwaddr_to_str
|
|
|
d41074 |
|
|
|
d41074 |
commit 5c3b78c92f8 introduced support for larger network hw addresses.
|
|
|
d41074 |
However, grub_net_hwaddr_to_str() relies on GRUB_NET_MAX_STR_ADDRESS_SIZE
|
|
|
d41074 |
to prevent a spurious ':' at the end of the string. So now, if actual
|
|
|
d41074 |
hwaddr size is less than max, an extra ':' appears at the end of the
|
|
|
d41074 |
string. So calculate max string size based on actual hwaddr length to
|
|
|
d41074 |
fix the problem.
|
|
|
d41074 |
|
|
|
d41074 |
Signed-off-by: Mark Salter <msalter@redhat.com>
|
|
|
d41074 |
---
|
|
|
d41074 |
grub-core/net/net.c | 4 +++-
|
|
|
d41074 |
1 file changed, 3 insertions(+), 1 deletion(-)
|
|
|
d41074 |
|
|
|
d41074 |
diff --git a/grub-core/net/net.c b/grub-core/net/net.c
|
|
|
d41074 |
index 6b4b10ba444..a6566bdb00a 100644
|
|
|
d41074 |
--- a/grub-core/net/net.c
|
|
|
d41074 |
+++ b/grub-core/net/net.c
|
|
|
d41074 |
@@ -784,6 +784,7 @@ grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str)
|
|
|
d41074 |
{
|
|
|
d41074 |
char *ptr;
|
|
|
d41074 |
unsigned i;
|
|
|
d41074 |
+ int maxstr;
|
|
|
d41074 |
|
|
|
d41074 |
if (addr->len > GRUB_NET_MAX_LINK_ADDRESS_SIZE)
|
|
|
d41074 |
{
|
|
|
d41074 |
@@ -792,9 +793,10 @@ grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str)
|
|
|
d41074 |
addr->type, addr->len);
|
|
|
d41074 |
return;
|
|
|
d41074 |
}
|
|
|
d41074 |
+ maxstr = addr->len * grub_strlen ("XX:");
|
|
|
d41074 |
for (ptr = str, i = 0; i < addr->len; i++)
|
|
|
d41074 |
{
|
|
|
d41074 |
- ptr += grub_snprintf (ptr, GRUB_NET_MAX_STR_HWADDR_LEN - (ptr - str),
|
|
|
d41074 |
+ ptr += grub_snprintf (ptr, maxstr - (ptr - str),
|
|
|
d41074 |
"%02x:", addr->mac[i] & 0xff);
|
|
|
d41074 |
}
|
|
|
d41074 |
}
|