From: Ian Campbell Subject: Re: [PATCH v2] libxc: fix retrieval of and remove pointless check on gzip size Date: Thu, 31 Oct 2013 22:07:12 +0000 Message-ID: <1383257232.5436.158.camel@dagon.hellion.org.uk> References: <1383119525-26033-3-git-send-email-mattjd@gmail.com> <1383188333-15407-1-git-send-email-mattjd@gmail.com> <52722F6A.9030900@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <52722F6A.9030900@citrix.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: Andrew Cooper Cc: Matthew Daley , Ian Jackson , Stefano Stabellini , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Thu, 2013-10-31 at 10:22 +0000, Andrew Cooper wrote: > On 31/10/13 02:58, Matthew Daley wrote: > > Coverity-ID: 1055587 > > Coverity-ID: 1055963 > > Signed-off-by: Matthew Daley > > Reviewed-by: Andrew Cooper I'd have used a few more ()s for clarity, but acked + applied. > > > --- > > v2: Cast to size_t instead of unsigned int, matching the type of > > unziplen. Suggested by Andrew Cooper. > > > > 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..3bf51ef 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 = (size_t)gzlen[3] << 24 | gzlen[2] << 16 | gzlen[1] << 8 | gzlen[0]; > > + if ( unziplen > XC_DOM_DECOMPRESS_MAX ) > > { > > xc_dom_printf > > (xch, >