grub2/0013-grub-core-lib-xzembed-xz_dec_stream.c-hash_validate-.patch
2013-05-02 16:54:52 -04:00

74 lines
2.0 KiB
Diff

From 4942f9b133e52828d2441309beea0e9278e8b80c Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Sun, 22 Jul 2012 16:27:03 +0200
Subject: [PATCH 013/364] * grub-core/lib/xzembed/xz_dec_stream.c
(hash_validate): Fix behaviour if hash function is unavailable.
(dec_stream_header): Likewise.
---
ChangeLog | 6 ++++++
grub-core/lib/xzembed/xz_dec_stream.c | 15 ++++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 38374a3..892d31b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2012-07-22 Vladimir Serbinenko <phcoder@gmail.com>
+ * grub-core/lib/xzembed/xz_dec_stream.c (hash_validate): Fix behaviour
+ if hash function is unavailable.
+ (dec_stream_header): Likewise.
+
+2012-07-22 Vladimir Serbinenko <phcoder@gmail.com>
+
* grub-core/normal/autofs.c (autoload_fs_module): Save and restore
filter state.
diff --git a/grub-core/lib/xzembed/xz_dec_stream.c b/grub-core/lib/xzembed/xz_dec_stream.c
index 0d79b1f..6170b0c 100644
--- a/grub-core/lib/xzembed/xz_dec_stream.c
+++ b/grub-core/lib/xzembed/xz_dec_stream.c
@@ -403,18 +403,25 @@ static enum xz_ret hash_validate(struct xz_dec *s, struct xz_buf *b,
}
#endif
- do {
+ if (b->in_pos == b->in_size)
+ return XZ_OK;
+
+ if (!crc32 && s->hash_size == 0)
+ s->pos += 8;
+
+ while (s->pos < (crc32 ? 32 : s->hash_size * 8)) {
if (b->in_pos == b->in_size)
return XZ_OK;
#ifndef GRUB_EMBED_DECOMPRESSOR
- if (hash && s->hash_value[s->pos / 8] != b->in[b->in_pos++])
+ if (hash && s->hash_value[s->pos / 8] != b->in[b->in_pos])
return XZ_DATA_ERROR;
#endif
+ b->in_pos++;
s->pos += 8;
- } while (s->pos < (crc32 ? 32 : s->hash_size * 8));
+ }
#ifndef GRUB_EMBED_DECOMPRESSOR
if (s->hash)
@@ -529,8 +536,6 @@ 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);
}
- if (!s->hash)
- return XZ_OPTIONS_ERROR;
#endif
}
else
--
1.8.1.4