=== modified file 'ChangeLog' --- ChangeLog 2011-01-13 21:25:56 +0000 +++ ChangeLog 2011-01-14 23:53:37 +0000 @@ -1,3 +1,8 @@ +2011-01-15 Szymon Janc + + * grub-core/kern/file.c (grub_file_read): Handle unknown file size. + (grub_file_seek): Likewise. + 2011-01-13 Vladimir Serbinenko * grub-core/fs/zfs/zfsinfo.c (grub_cmd_zfs_bootfs): Quote bootpath and === modified file 'grub-core/kern/file.c' --- grub-core/kern/file.c 2010-09-05 11:05:36 +0000 +++ grub-core/kern/file.c 2011-01-14 23:53:37 +0000 @@ -132,15 +132,18 @@ grub_file_read (grub_file_t file, void * { grub_ssize_t res; - if (file->offset > file->size) + if (file->size != GRUB_FILE_SIZE_UNKNOWN) { - grub_error (GRUB_ERR_OUT_OF_RANGE, - "attempt to read past the end of file"); - return -1; - } + if (file->offset > file->size) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, + "attempt to read past the end of file"); + return -1; + } - if (len == 0 || len > file->size - file->offset) - len = file->size - file->offset; + if (len == 0 || len > file->size - file->offset) + len = file->size - file->offset; + } /* Prevent an overflow. */ if ((grub_ssize_t) len < 0) @@ -171,16 +174,22 @@ grub_file_close (grub_file_t file) grub_off_t grub_file_seek (grub_file_t file, grub_off_t offset) { - grub_off_t old; + grub_off_t old = file->offset; + + if (file->size == GRUB_FILE_SIZE_UNKNOWN && offset > file->offset) + { + if (grub_file_read (file, NULL, offset - file->offset) < 0) + return -1; + else + return old; + } if (offset > file->size) { - grub_error (GRUB_ERR_OUT_OF_RANGE, - "attempt to seek outside of the file"); + grub_error (GRUB_ERR_OUT_OF_RANGE, "attempt to seek outside of the file"); return -1; } - old = file->offset; file->offset = offset; return old; }