On a Thursday in 2022, Eustance Wu wrote:
>From 7df034e93d392c734ac5c4f4148a3d05f9edce29 Mon Sep 17 00:00:00 2001
>From: WuLongTao <eustancewu@gmail.com>
>Date: Thu, 16 Jun 2022 10:43:29 +0800
>Subject: [PATCH] virMacAddrParse: Fix wrong termination character
>
>The judgment of the termination character should be the null character, not
>a space. Using spaces to judge, content can be injected into mac. such as:
>"70:af:e7:1f:3f:89\001
>injected".
>
>This will result in an error: "virNetSocketReadWire:1805 : End of file
>while reading data: Input/output error"
What steps did you take to get such error?
>---
> src/util/virmacaddr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c
>index 6b22384cee..5c4aa07713 100644
>--- a/src/util/virmacaddr.c
>+++ b/src/util/virmacaddr.c
>@@ -163,7 +163,7 @@ virMacAddrParse(const char* str, virMacAddr *addr)
>
> addr->addr[i] = (unsigned char) result;
>
>- if ((i == 5) && (*end_ptr <= ' '))
>+ if ((i == 5) && (*end_ptr <= 0))
The comparison is "less or equal", '\0' was already being used as a
termination character before this patch.
Jano
> return 0;
> if (*end_ptr != ':')
> break;
>--
>2.32.0