* [PATCH] xc_inflate_buffer fix
@ 2006-03-15 17:56 David Lively
2006-03-15 19:59 ` David Lively
2006-03-17 10:38 ` Keir Fraser
0 siblings, 2 replies; 3+ messages in thread
From: David Lively @ 2006-03-15 17:56 UTC (permalink / raw)
To: xen-devel
[-- Attachment #1: Type: text/plain, Size: 557 bytes --]
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
[-- Attachment #2: xc-inflate-buffer-fix.patch --]
[-- Type: text/x-patch, Size: 824 bytes --]
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 )
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xc_inflate_buffer fix
2006-03-15 17:56 [PATCH] xc_inflate_buffer fix David Lively
@ 2006-03-15 19:59 ` David Lively
2006-03-17 10:38 ` Keir Fraser
1 sibling, 0 replies; 3+ messages in thread
From: David Lively @ 2006-03-15 19:59 UTC (permalink / raw)
To: David Lively; +Cc: xen-devel
Oops, forgot:
Signed-off-by: David Lively <dlively@virtualiron.com>
Dave
David Lively wrote:
> 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
>
>
> ------------------------------------------------------------------------
>
> 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 )
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] xc_inflate_buffer fix
2006-03-15 17:56 [PATCH] xc_inflate_buffer fix David Lively
2006-03-15 19:59 ` David Lively
@ 2006-03-17 10:38 ` Keir Fraser
1 sibling, 0 replies; 3+ messages in thread
From: Keir Fraser @ 2006-03-17 10:38 UTC (permalink / raw)
To: David Lively; +Cc: xen-devel
On 15 Mar 2006, at 17:56, David Lively wrote:
> 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 ...
Yep, my bad. Thanks.
-- Keir
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-03-17 10:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-15 17:56 [PATCH] xc_inflate_buffer fix David Lively
2006-03-15 19:59 ` David Lively
2006-03-17 10:38 ` Keir Fraser
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.