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