fs/cpio_common: Add a sanity check on namesize.
Found by: Coverity scan.
This commit is contained in:
parent
b6f21bcb98
commit
faad548ce3
1 changed files with 8 additions and 0 deletions
|
@ -61,6 +61,14 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name,
|
||||||
modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
|
modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode));
|
||||||
namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
|
namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize));
|
||||||
|
|
||||||
|
/* Don't allow negative numbers. */
|
||||||
|
if (namesize >= 0x80000000)
|
||||||
|
{
|
||||||
|
/* Probably a corruption, don't attempt to recover. */
|
||||||
|
*mode = GRUB_ARCHELP_ATTR_END;
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
if (mode)
|
if (mode)
|
||||||
*mode = modeval;
|
*mode = modeval;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue