<div dir="ltr">Thanks a lot. <div><br><div>In libvirt of the latest code of the current master: When configuring the mac address of the DHCP host (c0:3b:04:21:15:35), if a space is added at the end (c0:3b:04:21:15:35\32 ), no error is thrown when starting the network.<br>I think an error should be thrown because such a mac (c0:3b:04:21:15:35\32) is not legal<br>And the mac address (c0:3b:04:21:15:35) does not take effect<br>The diagram is as follows:</div><div><img src="cid:ii_l4gpw3z01" alt="image.png" width="439" height="507"><br></div></div><div><br></div><div><pre style="white-space:pre-wrap;color:rgb(0,0,0)">><i> 
</i>><i>          addr->addr[i] = (unsigned char) result;
</i>><i> 
</i>><i> -        if ((i == 5) && (*end_ptr <= ' '))
</i>><i> +        if ((i == 5) && (*end_ptr == '\0'))
</i></pre><br class="gmail-Apple-interchange-newline"></div><div><br class="gmail-Apple-interchange-newline">Can I mention a patch for this issue?<br>Will this affect other functions?<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Peter Krempa <<a href="mailto:pkrempa@redhat.com">pkrempa@redhat.com</a>> 于2022年6月16日周四 14:52写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Jun 16, 2022 at 14:09:06 +0800, Eustance Wu wrote:<br>
> From ef22e53c9360ddb4bdff61a12013a2812fb7346a Mon Sep 17 00:00:00 2001<br>
> From: longtao <<a href="mailto:longtao.wu@zstack.io" target="_blank">longtao.wu@zstack.io</a>><br>
> Date: Thu, 16 Jun 2022 14:08:14 +0800<br>
> Subject: [PATCH] virMacAddrParse: Fix wrong termination character<br>
> <br>
> The judgment of the termination character should be the '\0' character, not<br>
> a space.<br>
> Using spaces to judge, content can be injected into mac. such as:<br>
> "70:af:e7:1f:3f:89\32injected".<br>
> <br>
> Before this patch, the terminating character was a space ('\32'),not '\0'.<br>
<br>
This sentence is inaccurate, it was any byte between 0 and ' '.<br>
<br>
> So I can set the DHCP host mac like this "<host mac='c0:3b:04:21:15:35<br>
>  injected' name='name129' ip='192.168.100.129'/>".<br>
<br>
This format does not conform to our XML schema. The 'mac' attribute is<br>
defined as:<br>
<br>
  <define name="uniMacAddr"><br>
    <data type="string"><br>
      <param name="pattern">[a-fA-F0-9][02468aAcCeE](:[a-fA-F0-9]{2}){5}</param><br>
    </data><br>
  </define><br>
<br>
Thus 'space' or any other character is _not_ allowed in int including<br>
the word 'injected'.<br>
<br>
What are you actually trying to achieve? This is not clear from the<br>
description in this bug.<br>
<br>
Please describe also the end goal ...<br>
<br>
> When running the network, no error is reported.<br>
> But, when using this mac to create a virtual machine,  Will get<br>
> "virNetSocketReadWire:1805 : End of file while reading data: Input/output<br>
<br>
... rather than just an error you are seeing, since this doesn't seem to<br>
be a plain bugfix.<br>
<br>
> error" in the libvirtd log.<br>
> ---<br>
>  src/util/virmacaddr.c | 2 +-<br>
>  1 file changed, 1 insertion(+), 1 deletion(-)<br>
> <br>
> diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c<br>
> index 6b22384cee..ba7c7e7076 100644<br>
> --- a/src/util/virmacaddr.c<br>
> +++ b/src/util/virmacaddr.c<br>
> @@ -163,7 +163,7 @@ virMacAddrParse(const char* str, virMacAddr *addr)<br>
<br>
This helper is used in many places, outside of the network driver, so<br>
this will need careful assesment whether any other code depends on the<br>
old behaviour.<br>
<br>
> <br>
>          addr->addr[i] = (unsigned char) result;<br>
> <br>
> -        if ((i == 5) && (*end_ptr <= ' '))<br>
> +        if ((i == 5) && (*end_ptr == 0))<br>
<br>
We prefer to use the character literal version of the nul byte ('\0').<br>
<br>
>              return 0;<br>
>          if (*end_ptr != ':')<br>
>              break;<br>
> -- <br>
> 2.32.0<br>
<br>
</blockquote></div>