[PATCH] virMacAddrParse: Fix wrong termination character

Eustance Wu eustancewu at gmail.com
Thu Jun 16 03:16:11 UTC 2022


>From 7df034e93d392c734ac5c4f4148a3d05f9edce29 Mon Sep 17 00:00:00 2001
From: WuLongTao <eustancewu at 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"
---
 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))
             return 0;
         if (*end_ptr != ':')
             break;
-- 
2.32.0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220616/963c232f/attachment.htm>


More information about the libvir-list mailing list