diff --git a/ChangeLog b/ChangeLog index 431bf4493..5e1498fa7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-01-23 Vladimir Serbinenko + + * 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 2012-01-22 Zachary Bedell 2012-01-22 Richard Laager diff --git a/grub-core/lib/xzembed/xz_dec_stream.c b/grub-core/lib/xzembed/xz_dec_stream.c index 09e5e513a..1d789d9ba 100644 --- a/grub-core/lib/xzembed/xz_dec_stream.c +++ b/grub-core/lib/xzembed/xz_dec_stream.c @@ -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 diff --git a/grub-core/normal/crypto.c b/grub-core/normal/crypto.c index 19dafd8a7..8e61255f3 100644 --- a/grub-core/normal/crypto.c +++ b/grub-core/normal/crypto.c @@ -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