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