]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Handling of files of unknown size is currently limited. They can't be
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 26 Dec 2010 20:15:31 +0000 (21:15 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 26 Dec 2010 20:15:31 +0000 (21:15 +0100)
used e.g. for initrd or modules. Moreover gzip handling of not
easily seekable files is buggy. Disable unknown file size for now. May
be inefficient but works.

* grub-core/io/gzio.c (test_header): Always retrieve the file size.
* grub-core/io/xzio.c (grub_xzio_open): Likewise.

ChangeLog
grub-core/io/gzio.c
grub-core/io/xzio.c

index 80f5ef56879fd1b0ea570ffc7af78eb4a4c3e85b..0c701a342a0020996970bd18224bff585062c5e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-12-26  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Handling of files of unknown size is currently limited. They can't be
+       used e.g. for initrd or modules. Moreover gzip handling of not
+       easily seekable files is buggy. Disable unknown file size for now. May
+       be inefficient but works.
+
+       * grub-core/io/gzio.c (test_header): Always retrieve the file size.
+       * grub-core/io/xzio.c (grub_xzio_open): Likewise.
+
 2010-12-25  Mirko Parthey <mirko.parthey@informatik.tu-chemnitz.de>
 
        * grub-core/boot/i386/pc/boot.S: Fix %es:%bx pointing to nowhere on
index 43b67c3738594cd638e8377f25b55e4f8ce1597e..f563d7b92c55882dbb227addbe66343cd3210f4f 100644 (file)
@@ -212,19 +212,18 @@ test_header (grub_file_t file)
 
   gzio->data_offset = grub_file_tell (gzio->file);
 
-  grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
-
-  if (grub_file_seekable (gzio->file))
-    {
-      if (grub_file_read (gzio->file, &orig_len, 4) != 4)
-       {
-         grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
-         return 0;
-       }
-    }
-  /* FIXME: this does not handle files whose original size is over 4GB.
-     But how can we know the real original size?  */
-  file->size = grub_le_to_cpu32 (orig_len);
+  /* FIXME: don't do this on not easily seekable files.  */
+  {
+    grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
+    if (grub_file_read (gzio->file, &orig_len, 4) != 4)
+      {
+       grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
+       return 0;
+      }
+    /* FIXME: this does not handle files whose original size is over 4GB.
+       But how can we know the real original size?  */
+    file->size = grub_le_to_cpu32 (orig_len);
+  }
 
   initialize_tables (file);
 
index 1a22bdc707aed5e0a45c93d9800bb29e0a29cfc6..37be1790fe2c5a15fd9b398c6636dd490b784bb3 100644 (file)
@@ -222,7 +222,8 @@ grub_xzio_open (grub_file_t io)
   xzio->buf.out_pos = 0;
   xzio->buf.out_size = XZBUFSIZ;
 
-  if (!test_header (file) || !(grub_file_seekable (io) && test_footer (file)))
+  /* FIXME: don't test footer on not easily seekable files.  */
+  if (!test_header (file) || !test_footer (file))
     {
       grub_errno = GRUB_ERR_NONE;
       grub_file_seek (io, 0);