]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/normal/crypto.c (grub_crypto_autoload): Prevent
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 23 Jan 2012 02:39:37 +0000 (03:39 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 23 Jan 2012 02:39:37 +0000 (03:39 +0100)
infinite recursion using counter.
* grub-core/lib/xzembed/xz_dec_stream.c (xz_dec_init): Defer s->crc32
init to skip it if the magic check fails.
(dec_stream_header): Init s->crc32.

ChangeLog
grub-core/lib/xzembed/xz_dec_stream.c
grub-core/normal/crypto.c

index 431bf4493454b49534de6efb2fcc6c08a1f2bfa5..5e1498fa799ac0f3c1c8fef3e18e62fc237227aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-01-23  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/normal/crypto.c (grub_crypto_autoload): Prevent
+       infinite recursion using counter.
+       * grub-core/lib/xzembed/xz_dec_stream.c (xz_dec_init): Defer s->crc32
+       init to skip it if the magic check fails.
+       (dec_stream_header): Init s->crc32.
+
 2012-01-22  Vladimir Serbinenko  <phcoder@gmail.com>
 2012-01-22  Zachary Bedell <pendorbound@gmail.com>
 2012-01-22  Richard Laager <rlaager@wiktel.com>
index 09e5e513a7616076950fe06f88d402c71f7930ab..1d789d9ba959b1ce398c67e966447059cc34052f 100644 (file)
@@ -445,6 +445,8 @@ static enum xz_ret dec_stream_header(struct xz_dec *s)
                return XZ_FORMAT_ERROR;
 
 #ifndef GRUB_EMBED_DECOMPRESSOR
+       s->crc32 = grub_crypto_lookup_md_by_name ("CRC32");
+
        if (s->crc32)
        {
                uint64_t hash_context[(s->crc32->contextsize + 7) / 8];
@@ -958,10 +960,6 @@ struct xz_dec * xz_dec_init(uint32_t dict_max)
 
        memset (s, 0, sizeof (*s));
 
-#ifndef GRUB_EMBED_DECOMPRESSOR
-       s->crc32 = grub_crypto_lookup_md_by_name ("CRC32");
-#endif
-
        s->single_call = dict_max == 0;
 
 #ifdef XZ_DEC_BCJ
index 19dafd8a7f2493a1098249b54e85c3b84bb1e516..8e61255f37a4fcff91b3e2e908b7d84b54182d8d 100644 (file)
@@ -38,7 +38,14 @@ grub_crypto_autoload (const char *name)
 {
   struct load_spec *cur;
   grub_dl_t mod;
-  
+  static int depth = 0;
+
+  /* Some bufio of filesystems may want some crypto modules.
+     It may result in infinite recursion. Hence this check.  */
+  if (depth)
+    return;
+  depth++;
+
   for (cur = crypto_specs; cur; cur = cur->next)
     if (grub_strcasecmp (name, cur->name) == 0)
       {
@@ -47,6 +54,7 @@ grub_crypto_autoload (const char *name)
          grub_dl_ref (mod);
        grub_errno = GRUB_ERR_NONE;
       }
+  depth--;
 }
 
 static void