From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Lively Subject: [PATCH] xc_inflate_buffer fix Date: Wed, 15 Mar 2006 12:56:55 -0500 Message-ID: <44185567.6070805@virtualiron.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040603080107040602000906" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------040603080107040602000906 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi - I notice some of my initrds are failing to gunzip: ERROR: inflate failed, sts -5 These same initrds work fine with Ben Thomas' original patch introducing xc_{linux,hvm}_build_mem. The checked-in version changed some declarations from unsigned char * to char *, breaking the output length computation in xc_inflate_buffer. This patch assumes you want to keep using the signed char * for the interface, so it simply inserts a few casts to unsigned. Tested lightly, but the bug is pretty obvious once you notice the signedness change ... Dave --------------040603080107040602000906 Content-Type: text/x-patch; name="xc-inflate-buffer-fix.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xc-inflate-buffer-fix.patch" diff -r 1d741a415927 tools/libxc/xg_private.c --- a/tools/libxc/xg_private.c Wed Mar 15 11:48:33 2006 -0500 +++ b/tools/libxc/xg_private.c Wed Mar 15 12:28:05 2006 -0500 @@ -77,10 +77,11 @@ char *xc_inflate_buffer(const char *in_b return (char *)in_buf; } - out_len = in_buf[in_size-4] + - (256 * (in_buf[in_size-3] + - (256 * (in_buf[in_size-2] + - (256 * in_buf[in_size-1]))))); + out_len = (unsigned char)in_buf[in_size-4] + + (256 * ((unsigned char)in_buf[in_size-3] + + (256 * ((unsigned char)in_buf[in_size-2] + + (256 * (unsigned char)in_buf[in_size-1]))))); + bzero(&zStream, sizeof(zStream)); out_buf = malloc(out_len + 16); /* Leave a little extra space */ if ( out_buf == NULL ) --------------040603080107040602000906 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------040603080107040602000906--