* grub-core/kern/file.c (grub_file_read): Read nothing if len = 0.
Special behaviour for len = 0 to read whole file isn't used anywhere and can cause buffer ovewrflows in several places.
This commit is contained in:
parent
f0a53ed2c2
commit
a188012e6c
2 changed files with 10 additions and 1 deletions
|
@ -143,7 +143,10 @@ grub_file_read (grub_file_t file, void *buf, grub_size_t len)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (len == 0 || len > file->size - file->offset)
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
if (len > file->size - file->offset)
|
||||
len = file->size - file->offset;
|
||||
|
||||
/* Prevent an overflow. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue