]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-104282: Fix null pointer dereference in `lzma._decode_filter_properties...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 17 Jan 2024 13:31:33 +0000 (14:31 +0100)
committerGitHub <noreply@github.com>
Wed, 17 Jan 2024 13:31:33 +0000 (13:31 +0000)
(cherry picked from commit 0154405350c272833bd51f68138223655e142a37)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
Lib/test/test_lzma.py
Misc/NEWS.d/next/Library/2023-05-08-09-30-00.gh-issue-104282.h4c6Eb.rst [new file with mode: 0644]
Modules/_lzmamodule.c

index 13b200912f6abda4019fa3705a6505d066d43a2e..65e6488c5d7b106b4b7ba73cb4c5809c81d45c3a 100644 (file)
@@ -1401,6 +1401,14 @@ class MiscellaneousTestCase(unittest.TestCase):
         self.assertEqual(filterspec["lc"], 3)
         self.assertEqual(filterspec["dict_size"], 8 << 20)
 
+        # see gh-104282
+        filters = [lzma.FILTER_X86, lzma.FILTER_POWERPC,
+                   lzma.FILTER_IA64, lzma.FILTER_ARM,
+                   lzma.FILTER_ARMTHUMB, lzma.FILTER_SPARC]
+        for f in filters:
+            filterspec = lzma._decode_filter_properties(f, b"")
+            self.assertEqual(filterspec, {"id": f})
+
     def test_filter_properties_roundtrip(self):
         spec1 = lzma._decode_filter_properties(
                 lzma.FILTER_LZMA1, b"]\x00\x00\x80\x00")
diff --git a/Misc/NEWS.d/next/Library/2023-05-08-09-30-00.gh-issue-104282.h4c6Eb.rst b/Misc/NEWS.d/next/Library/2023-05-08-09-30-00.gh-issue-104282.h4c6Eb.rst
new file mode 100644 (file)
index 0000000..569ce66
--- /dev/null
@@ -0,0 +1,3 @@
+Fix null pointer dereference in :func:`lzma._decode_filter_properties`
+due to improper handling of BCJ filters with properties of zero length.
+Patch by Radislav Chugunov.
index e34fbad230d51ae7ab0792cf273e8618f1a796f8..7bbd6569aa2e44974b8d481777a3430ca6dff5f0 100644 (file)
@@ -494,7 +494,9 @@ build_filter_spec(const lzma_filter *f)
         case LZMA_FILTER_ARMTHUMB:
         case LZMA_FILTER_SPARC: {
             lzma_options_bcj *options = f->options;
-            ADD_FIELD(options, start_offset);
+            if (options) {
+                ADD_FIELD(options, start_offset);
+            }
             break;
         }
         default: