From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 02/29] libxc: fix retrieval of and remove pointless check on gzip size Date: Wed, 30 Oct 2013 10:50:35 +0000 Message-ID: <5270E47B.1050909@citrix.com> References: <1383119525-26033-1-git-send-email-mattjd@gmail.com> <1383119525-26033-3-git-send-email-mattjd@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1383119525-26033-3-git-send-email-mattjd@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Matthew Daley Cc: Stefano Stabellini , Ian Jackson , Ian Campbell , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 30/10/13 07:51, Matthew Daley wrote: > Coverity-ID: 1055587 > Coverity-ID: 1055963 > Signed-off-by: Matthew Daley > --- > tools/libxc/xc_dom_core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c > index 0f367f6..c9366a9 100644 > --- a/tools/libxc/xc_dom_core.c > +++ b/tools/libxc/xc_dom_core.c > @@ -294,8 +294,8 @@ size_t xc_dom_check_gzip(xc_interface *xch, void *blob, size_t ziplen) > return 0; > > gzlen = blob + ziplen - 4; > - unziplen = gzlen[3] << 24 | gzlen[2] << 16 | gzlen[1] << 8 | gzlen[0]; > - if ( (unziplen < 0) || (unziplen > XC_DOM_DECOMPRESS_MAX) ) > + unziplen = (unsigned int)gzlen[3] << 24 | gzlen[2] << 16 | gzlen[1] << 8 | gzlen[0]; This is very minor, but might it be better to cast to size_t, to match unziplen ? Either way, the result will now be correct. ~Andrew > + if ( unziplen > XC_DOM_DECOMPRESS_MAX ) > { > xc_dom_printf > (xch,