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