grub2/0013-grub-core-lib-xzembed-xz_dec_stream.c-hash_validate-.patch
Peter Jones f74b50e380 Rebase to upstream, fix a pile of bugs. The usual.
Signed-off-by: Peter Jones <pjones@redhat.com>
2013-06-12 15:37:08 -04:00

73 lines
2 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/482] * 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.2.1