]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/lib/xzembed/xz_dec_stream.c (hash_validate): Fix behaviour
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 22 Jul 2012 14:27:03 +0000 (16:27 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 22 Jul 2012 14:27:03 +0000 (16:27 +0200)
if hash function is unavailable.
(dec_stream_header): Likewise.

ChangeLog
grub-core/lib/xzembed/xz_dec_stream.c

index 38374a33ffcf307e817a37b560f66686aa8c20f9..892d31bd1660f04d2f837f3f7b40ea3b7e7af682 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+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
index 0d79b1f0bc8d016161bdbb23e24fc9c9856feefd..6170b0c5cdd4b84d1428b97f19bfd6b7551bc20e 100644 (file)
@@ -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