From f6e4ea709fb3db6bba7e96bc21584662b40991fc Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 27 Jan 2012 13:09:57 +0100 Subject: [PATCH] * grub-core/fs/squash4.c (xz_decompress): Fix return value. (direct_read): Use correct compressed size. (grub_squash_read_data): Likewise. --- ChangeLog | 8 +++++++- grub-core/fs/squash4.c | 16 +++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3d76423f..500105c62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2012-01-25 Vladimir Serbinenko +2012-01-26 Vladimir Serbinenko + + * grub-core/fs/squash4.c (xz_decompress): Fix return value. + (direct_read): Use correct compressed size. + (grub_squash_read_data): Likewise. + +2012-01-26 Vladimir Serbinenko * docs/grub.texi (Platform limitations): New section. (Platform-specific operations): Likewise. diff --git a/grub-core/fs/squash4.c b/grub-core/fs/squash4.c index 4ef4cf5df..d012564a8 100644 --- a/grub-core/fs/squash4.c +++ b/grub-core/fs/squash4.c @@ -317,7 +317,7 @@ static grub_ssize_t xz_decompress (char *inbuf, grub_size_t insize, grub_off_t off, char *outbuf, grub_size_t len, struct grub_squash_data *data) { - grub_size_t ret; + grub_size_t ret = 0; grub_off_t pos = 0; struct xz_buf buf; @@ -778,7 +778,9 @@ direct_read (struct grub_squash_data *data, & grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED))) { char *block; - block = grub_malloc (data->blksz); + grub_size_t csize; + csize = grub_le_to_cpu32 (ino->block_sizes[i]) & ~SQUASH_BLOCK_FLAGS; + block = grub_malloc (csize); if (!block) return -1; err = grub_disk_read (data->disk, @@ -786,13 +788,13 @@ direct_read (struct grub_squash_data *data, >> GRUB_DISK_SECTOR_BITS, (ino->cumulated_block_sizes[i] + a) & (GRUB_DISK_SECTOR_SIZE - 1), - data->blksz, block); + csize, block); if (err) { grub_free (block); return -1; } - if (data->decompress (block, data->blksz, boff, buf, read, data) + if (data->decompress (block, csize, boff, buf, read, data) != (grub_ssize_t) read) { grub_free (block); @@ -862,19 +864,19 @@ grub_squash_read_data (struct grub_squash_data *data, if (compressed) { char *block; - block = grub_malloc (data->blksz); + block = grub_malloc (frag.size); if (!block) return -1; err = grub_disk_read (data->disk, a >> GRUB_DISK_SECTOR_BITS, a & (GRUB_DISK_SECTOR_SIZE - 1), - data->blksz, block); + frag.size, block); if (err) { grub_free (block); return -1; } - if (data->decompress (block, data->blksz, b, buf, len, data) + if (data->decompress (block, frag.size, b, buf, len, data) != (grub_ssize_t) len) { grub_free (block);