In libbacktrace, the RLE sequence code in the zstd decompressor failed
to initialize the table field. This patch from Ivan Molodetskikh fixes
the problem. Ran libbacktrace tests on x86_64-pc-linux-gnu. Committed
to mainline.

Ian

* elf.c (elf_zstd_unpack_seq_decode): Set table field for RLE
sequence.
* zstdtest.c (tests): Add rle-sequence-tables test.
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 0de12bc112e..e1c34584578 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -4302,6 +4302,7 @@ elf_zstd_unpack_seq_decode (int mode,
        decode->table_bits = 0;
        if (!conv (&entry, 0, table))
          return 0;
+       decode->table = table;
       }
       break;
 
diff --git a/libbacktrace/zstdtest.c b/libbacktrace/zstdtest.c
index db8072645b9..202b5b94402 100644
--- a/libbacktrace/zstdtest.c
+++ b/libbacktrace/zstdtest.c
@@ -208,6 +208,24 @@ static const struct zstd_test tests[] =
      "\x4c\x1f\xf9\xf1"),
     30,
   },
+  {
+    "rle-sequence-tables",
+    "AAAA",
+    0,
+    ("\x28\xb5\x2f\xfd"
+     "\x20" /* Single_Segment_flag; Frame_Content_Size_flag = 0 */
+     "\x04" /* Frame_Content_Size */
+     "\x45\x00\x00" /* Last_Block, Compressed_Block, size 8 */
+     "\x08" /* Raw_Literals_Block, Regenerated_Size 1 */
+     "A"
+     "\x01" /* Number_of_Sequences */
+     "\x54" /* RLE literals length, offset, and match length tables */
+     "\x01" /* literal length code: 1 */
+     "\x00" /* offset code: repeat offset 1 */
+     "\x00" /* match length code: 3 */
+     "\x80"), /* bitstream end marker */
+    17,
+  },
 };
 
 /* Test the hand coded samples.  */

Reply via email to