* grub-core/fs/squash4.c (xz_decompress): Fix return value.

(direct_read): Use correct compressed size.
	(grub_squash_read_data): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-01-27 13:09:57 +01:00
parent ca1dacea3c
commit f6e4ea709f
2 changed files with 16 additions and 8 deletions

View file

@ -1,4 +1,10 @@
2012-01-25 Vladimir Serbinenko <phcoder@gmail.com> 2012-01-26 Vladimir Serbinenko <phcoder@gmail.com>
* 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 <phcoder@gmail.com>
* docs/grub.texi (Platform limitations): New section. * docs/grub.texi (Platform limitations): New section.
(Platform-specific operations): Likewise. (Platform-specific operations): Likewise.

View file

@ -317,7 +317,7 @@ static grub_ssize_t
xz_decompress (char *inbuf, grub_size_t insize, grub_off_t off, xz_decompress (char *inbuf, grub_size_t insize, grub_off_t off,
char *outbuf, grub_size_t len, struct grub_squash_data *data) 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; grub_off_t pos = 0;
struct xz_buf buf; struct xz_buf buf;
@ -778,7 +778,9 @@ direct_read (struct grub_squash_data *data,
& grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED))) & grub_cpu_to_le32_compile_time (SQUASH_BLOCK_UNCOMPRESSED)))
{ {
char *block; 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) if (!block)
return -1; return -1;
err = grub_disk_read (data->disk, err = grub_disk_read (data->disk,
@ -786,13 +788,13 @@ direct_read (struct grub_squash_data *data,
>> GRUB_DISK_SECTOR_BITS, >> GRUB_DISK_SECTOR_BITS,
(ino->cumulated_block_sizes[i] + a) (ino->cumulated_block_sizes[i] + a)
& (GRUB_DISK_SECTOR_SIZE - 1), & (GRUB_DISK_SECTOR_SIZE - 1),
data->blksz, block); csize, block);
if (err) if (err)
{ {
grub_free (block); grub_free (block);
return -1; 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_ssize_t) read)
{ {
grub_free (block); grub_free (block);
@ -862,19 +864,19 @@ grub_squash_read_data (struct grub_squash_data *data,
if (compressed) if (compressed)
{ {
char *block; char *block;
block = grub_malloc (data->blksz); block = grub_malloc (frag.size);
if (!block) if (!block)
return -1; return -1;
err = grub_disk_read (data->disk, err = grub_disk_read (data->disk,
a >> GRUB_DISK_SECTOR_BITS, a >> GRUB_DISK_SECTOR_BITS,
a & (GRUB_DISK_SECTOR_SIZE - 1), a & (GRUB_DISK_SECTOR_SIZE - 1),
data->blksz, block); frag.size, block);
if (err) if (err)
{ {
grub_free (block); grub_free (block);
return -1; 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_ssize_t) len)
{ {
grub_free (block); grub_free (block);