[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH V3] net/colo-compare.c: Fix memory leak and code
From: |
Zhang, Chen |
Subject: |
Re: [Qemu-devel] [PATCH V3] net/colo-compare.c: Fix memory leak and code style issue. |
Date: |
Fri, 19 Jul 2019 01:54:55 +0000 |
> -----Original Message-----
> From: Peter Maydell [mailto:address@hidden]
> Sent: Thursday, July 18, 2019 9:42 PM
> To: Zhang, Chen <address@hidden>
> Cc: Li Zhijian <address@hidden>; Jason Wang <address@hidden>;
> qemu-dev <address@hidden>; Zhang Chen <address@hidden>
> Subject: Re: [PATCH V3] net/colo-compare.c: Fix memory leak and code style
> issue.
>
> On Thu, 18 Jul 2019 at 10:27, Zhang Chen <address@hidden> wrote:
> >
> > From: Zhang Chen <address@hidden>
> >
> > This patch to fix the origin "char *data" menory leak, code style
> > issue and add necessary check here.
> > Reported-by: Coverity (CID 1402785)
> >
> > Signed-off-by: Zhang Chen <address@hidden>
> > ---
> > net/colo-compare.c | 28 +++++++++++++++++++++-------
> > 1 file changed, 21 insertions(+), 7 deletions(-)
> >
> > diff --git a/net/colo-compare.c b/net/colo-compare.c index
> > 909dd6c6eb..fcccb4c6f6 100644
> > --- a/net/colo-compare.c
> > +++ b/net/colo-compare.c
> > @@ -127,6 +127,17 @@ static int compare_chr_send(CompareState *s,
> > uint32_t vnet_hdr_len,
> > bool notify_remote_frame);
> >
> > +static bool packet_matches_str(const char *str,
> > + uint8_t *buf,
> > + uint32_t packet_len) {
> > + if (packet_len != strlen(str)) {
>
> Is '!=' definitely correct? (ie the incoming packet must
> *not* contain a trailing '\0' or any other trailing data) ?
Yes, the packet not contain a trail.
As Jason comments before, you can see the net/net.c "net_fill_rstate()".
We just got the length and data.
Thanks
Zhang Chen
>
> Is there a specification of the protocol somewhere? If so, that presumably
> should say one way or the other.
>
> > + return false;
> > + }
> > +
> > + return !memcmp(str, buf, strlen(str)); }
>
> thanks
> -- PMM