lkml.org 
[lkml]   [2011]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] SquashFS, XZ: Don't use uninitialized variable in squashfs_xz_uncompress
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;


--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.



\
 
 \ /
  Last update: 2011-01-20 21:55    [W:0.037 / U:9.836 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site