grub-core/fs/minix.c (grub_minix_read_file): Avoid reading past the end of file.

This commit is contained in:
Vladimir Serbinenko 2015-01-20 13:55:55 +01:00
parent af435524cd
commit 30e177a05b
3 changed files with 18 additions and 1 deletions

View file

@ -262,6 +262,13 @@ grub_minix_read_file (struct grub_minix_data *data,
grub_uint32_t posblock;
grub_uint32_t blockoff;
if (pos > GRUB_MINIX_INODE_SIZE (data))
{
grub_error (GRUB_ERR_OUT_OF_RANGE,
N_("attempt to read past the end of file"));
return -1;
}
/* Adjust len so it we can't read past the end of the file. */
if (len + pos > GRUB_MINIX_INODE_SIZE (data))
len = GRUB_MINIX_INODE_SIZE (data) - pos;