From: Andrew Morton <akpm@linux-foundation.org>
To: Jesper Juhl <jj@chaosbits.net>
Cc: Phillip Lougher <phillip@lougher.demon.co.uk>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] SquashFS, XZ: Don't use uninitialized variable in squashfs_xz_uncompress
Date: Mon, 24 Jan 2011 14:43:53 -0800 [thread overview]
Message-ID: <20110124144353.c04c77b4.akpm@linux-foundation.org> (raw)
In-Reply-To: <alpine.LNX.2.00.1101202140070.11854@swampdragon.chaosbits.net>
On Thu, 20 Jan 2011 21:53:23 +0100 (CET)
Jesper Juhl <jj@chaosbits.net> wrote:
> In fs/squashfs/xz_wrapper.c::squashfs_xz_uncompress() we have this code:
>
> enum xz_ret xz_err;
> ...
> do {
> if (stream->buf.in_pos == stream->buf.in_size && k < b) {
> ... [nothing that assigns to 'xz_err'] ...
> if (avail == 0) {
> offset = 0;
> put_bh(bh[k++]);
> continue;
> }
> ...
> } while (xz_err == XZ_OK);
>
> If we hit that 'continue' statement the first time through, then the
> 'while' condition will be testing an uninitialized 'xz_err' - not what we
> want.
>
> This patch should take care of the problem by making sure that 'xz_err' is
> initialized to 'XZ_OK' at the start of the function.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
> xz_wrapper.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> compile tested only.
>
> diff --git a/fs/squashfs/xz_wrapper.c b/fs/squashfs/xz_wrapper.c
> index 856756c..daf76c3 100644
> --- a/fs/squashfs/xz_wrapper.c
> +++ b/fs/squashfs/xz_wrapper.c
> @@ -74,7 +74,7 @@ static int squashfs_xz_uncompress(struct squashfs_sb_info *msblk, void **buffer,
> struct buffer_head **bh, int b, int offset, int length, int srclength,
> int pages)
> {
> - enum xz_ret xz_err;
> + enum xz_ret xz_err = XZ_OK;
> int avail, total = 0, k = 0, page = 0;
> struct squashfs_xz *stream = msblk->stream;
>
hm, maybe. The handling of the `avail == 0' case looks odd. It sits
there in a loop doing wait_on_buffer() against buffers which it will
never use and possible reporting -EIO for a buffer which it didn't use,
which seems bogus.
Phillip, please check?
next prev parent reply other threads:[~2011-01-24 22:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-20 20:53 Jesper Juhl
2011-01-24 22:43 ` Andrew Morton [this message]
2011-01-24 23:30 ` Phillip Lougher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110124144353.c04c77b4.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=phillip@lougher.demon.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®