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.
This commit is contained in:
parent
9bb182f371
commit
f7ce5bafb5
2 changed files with 18 additions and 11 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2011-11-11 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
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 <phcoder@gmail.com>
|
2011-11-11 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Issue
|
* grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Issue
|
||||||
|
|
|
@ -78,9 +78,9 @@ struct xz_dec {
|
||||||
#ifndef GRUB_EMBED_DECOMPRESSOR
|
#ifndef GRUB_EMBED_DECOMPRESSOR
|
||||||
const gcry_md_spec_t *hash;
|
const gcry_md_spec_t *hash;
|
||||||
const gcry_md_spec_t *crc32;
|
const gcry_md_spec_t *crc32;
|
||||||
|
grub_uint8_t hash_id;
|
||||||
#endif
|
#endif
|
||||||
grub_size_t hash_size;
|
grub_size_t hash_size;
|
||||||
grub_uint8_t hash_id;
|
|
||||||
|
|
||||||
/* True if we are operating in single-call mode. */
|
/* True if we are operating in single-call mode. */
|
||||||
bool single_call;
|
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;
|
return XZ_STREAM_END;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef GRUB_EMBED_DECOMPRESSOR
|
static const struct
|
||||||
static struct
|
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
grub_size_t size;
|
grub_size_t size;
|
||||||
|
@ -438,7 +437,6 @@ static struct
|
||||||
[0x04] = { "CRC64", 8},
|
[0x04] = { "CRC64", 8},
|
||||||
[0x0A] = { "SHA256", 32},
|
[0x0A] = { "SHA256", 32},
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */
|
/* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */
|
||||||
static enum xz_ret dec_stream_header(struct xz_dec *s)
|
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
|
#endif
|
||||||
|
|
||||||
|
#ifndef GRUB_EMBED_DECOMPRESSOR
|
||||||
/*
|
/*
|
||||||
* Decode the Stream Flags field. Of integrity checks, we support
|
* Decode the Stream Flags field.
|
||||||
* only none (Check ID = 0) and CRC32 (Check ID = 1).
|
|
||||||
*/
|
*/
|
||||||
if (s->temp.buf[HEADER_MAGIC_SIZE] != 0
|
if (s->temp.buf[HEADER_MAGIC_SIZE] != 0
|
||||||
|| s->temp.buf[HEADER_MAGIC_SIZE + 1] >= ARRAY_SIZE (hashes)
|
|| 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];
|
s->hash_id = s->temp.buf[HEADER_MAGIC_SIZE + 1];
|
||||||
|
|
||||||
#ifndef GRUB_EMBED_DECOMPRESSOR
|
|
||||||
if (s->crc32)
|
if (s->crc32)
|
||||||
{
|
{
|
||||||
s->crc32_context = kmalloc(s->crc32->contextsize, GFP_KERNEL);
|
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->index.hash.hash_context);
|
||||||
s->hash->init(s->block.hash.hash_context);
|
s->hash->init(s->block.hash.hash_context);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
s->hash = 0;
|
|
||||||
#endif
|
|
||||||
#if 1
|
|
||||||
if (!s->hash)
|
if (!s->hash)
|
||||||
return XZ_OPTIONS_ERROR;
|
return XZ_OPTIONS_ERROR;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifndef GRUB_EMBED_DECOMPRESSOR
|
||||||
s->hash = 0;
|
s->hash = 0;
|
||||||
|
#endif
|
||||||
s->hash_size = 0;
|
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))
|
if ((s->index.size >> 2) != get_le32(s->temp.buf + 4))
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
|
||||||
|
#ifndef GRUB_EMBED_DECOMPRESSOR
|
||||||
if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->hash_id)
|
if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->hash_id)
|
||||||
return XZ_DATA_ERROR;
|
return XZ_DATA_ERROR;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use XZ_STREAM_END instead of XZ_OK to be more convenient
|
* Use XZ_STREAM_END instead of XZ_OK to be more convenient
|
||||||
|
|
Loading…
Reference in a new issue