From f7ce5bafb56ebeb2121c2d35eb98293f3e98acd0 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 11 Nov 2011 18:30:34 +0100 Subject: [PATCH] Fix mips compilation. * grub-core/lib/xzembed/xz_dec_stream.c (xz_dec): Restrict hash_id to normal decoder. (hashes): Use in embed decoder as well (for sizes). (dec_stream_header): Fix embed decompressor logic. (dec_stream_footer): Likewise. --- ChangeLog | 10 ++++++++++ grub-core/lib/xzembed/xz_dec_stream.c | 19 ++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0a790c10..ca07d5cab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-11-11 Vladimir Serbinenko + + Fix mips compilation. + + * grub-core/lib/xzembed/xz_dec_stream.c (xz_dec): Restrict hash_id to + normal decoder. + (hashes): Use in embed decoder as well (for sizes). + (dec_stream_header): Fix embed decompressor logic. + (dec_stream_footer): Likewise. + 2011-11-11 Vladimir Serbinenko * grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Issue diff --git a/grub-core/lib/xzembed/xz_dec_stream.c b/grub-core/lib/xzembed/xz_dec_stream.c index 383c29a2f..09e5e513a 100644 --- a/grub-core/lib/xzembed/xz_dec_stream.c +++ b/grub-core/lib/xzembed/xz_dec_stream.c @@ -78,9 +78,9 @@ struct xz_dec { #ifndef GRUB_EMBED_DECOMPRESSOR const gcry_md_spec_t *hash; const gcry_md_spec_t *crc32; + grub_uint8_t hash_id; #endif grub_size_t hash_size; - grub_uint8_t hash_id; /* True if we are operating in single-call mode. */ bool single_call; @@ -428,8 +428,7 @@ static enum xz_ret hash_validate(struct xz_dec *s, struct xz_buf *b, return XZ_STREAM_END; } -#ifndef GRUB_EMBED_DECOMPRESSOR -static struct +static const struct { const char *name; grub_size_t size; @@ -438,7 +437,6 @@ static struct [0x04] = { "CRC64", 8}, [0x0A] = { "SHA256", 32}, }; -#endif /* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */ static enum xz_ret dec_stream_header(struct xz_dec *s) @@ -470,9 +468,9 @@ static enum xz_ret dec_stream_header(struct xz_dec *s) } #endif +#ifndef GRUB_EMBED_DECOMPRESSOR /* - * Decode the Stream Flags field. Of integrity checks, we support - * only none (Check ID = 0) and CRC32 (Check ID = 1). + * Decode the Stream Flags field. */ if (s->temp.buf[HEADER_MAGIC_SIZE] != 0 || s->temp.buf[HEADER_MAGIC_SIZE + 1] >= ARRAY_SIZE (hashes) @@ -482,7 +480,6 @@ static enum xz_ret dec_stream_header(struct xz_dec *s) s->hash_id = s->temp.buf[HEADER_MAGIC_SIZE + 1]; -#ifndef GRUB_EMBED_DECOMPRESSOR if (s->crc32) { s->crc32_context = kmalloc(s->crc32->contextsize, GFP_KERNEL); @@ -530,17 +527,15 @@ static enum xz_ret dec_stream_header(struct xz_dec *s) s->hash->init(s->index.hash.hash_context); s->hash->init(s->block.hash.hash_context); } -#else - s->hash = 0; -#endif -#if 1 if (!s->hash) return XZ_OPTIONS_ERROR; #endif } else { +#ifndef GRUB_EMBED_DECOMPRESSOR s->hash = 0; +#endif s->hash_size = 0; } @@ -589,8 +584,10 @@ static enum xz_ret dec_stream_footer(struct xz_dec *s) if ((s->index.size >> 2) != get_le32(s->temp.buf + 4)) return XZ_DATA_ERROR; +#ifndef GRUB_EMBED_DECOMPRESSOR if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->hash_id) return XZ_DATA_ERROR; +#endif /* * Use XZ_STREAM_END instead of XZ_OK to be more convenient