zfs: add missing NULL check and fix incorrect buffer overwrite
grub_memset should zero out padding after data end. It is not clear why it is needed at all - ZFS block is at least 512 bytes and power of two, so it is always multiple of 16 bytes. This grub_memset apparently never did anything.
This commit is contained in:
parent
4a7ea4003b
commit
6210b8e8f7
1 changed files with 7 additions and 7 deletions
|
@ -1887,14 +1887,12 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf,
|
|||
"compression algorithm %s not supported\n", decomp_table[comp].name);
|
||||
|
||||
if (comp != ZIO_COMPRESS_OFF)
|
||||
{
|
||||
/* It's not really necessary to align to 16, just for safety. */
|
||||
compbuf = grub_malloc (ALIGN_UP (psize, 16));
|
||||
if (! compbuf)
|
||||
return grub_errno;
|
||||
}
|
||||
/* It's not really necessary to align to 16, just for safety. */
|
||||
compbuf = grub_malloc (ALIGN_UP (psize, 16));
|
||||
else
|
||||
compbuf = *buf = grub_malloc (lsize);
|
||||
if (! compbuf)
|
||||
return grub_errno;
|
||||
|
||||
grub_dprintf ("zfs", "endian = %d\n", endian);
|
||||
if (BP_IS_EMBEDDED(bp))
|
||||
|
@ -1902,7 +1900,9 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf,
|
|||
else
|
||||
{
|
||||
err = zio_read_data (bp, endian, compbuf, data);
|
||||
grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize);
|
||||
/* FIXME is it really necessary? */
|
||||
if (comp != ZIO_COMPRESS_OFF)
|
||||
grub_memset (compbuf + psize, 0, ALIGN_UP (psize, 16) - psize);
|
||||
}
|
||||
if (err)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue