integ/grub/grub2/centos/patches/1002-Don-t-write-trailing-colon-when-populating-MAC-strin.patch
slin14 11c474e8de rebase grub2 patch to CentOS7.5
Story: 2003389
Task: 24495

Change-Id: Ia5ccf65e9c3e462710694f1e860bf4281339ca85
Signed-off-by: slin14 <shuicheng.lin@intel.com>
2018-08-27 03:03:28 +00:00

37 lines
989 B
Diff

From 56561f1b5850888c9266b1155d4ac6d352e791c4 Mon Sep 17 00:00:00 2001
From: root <root@yow-cgts1-lx.wrs.com>
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
@@ -794,11 +794,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