mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.12] gh-104282: Fix null pointer dereference in lzma._decode_filter_properties
(GH-104283) (GH-114181)
(cherry picked from commit 0154405350
)
Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
This commit is contained in:
parent
27941b14ab
commit
00e7793519
3 changed files with 14 additions and 1 deletions
|
@ -1401,6 +1401,14 @@ class MiscellaneousTestCase(unittest.TestCase):
|
||||||
self.assertEqual(filterspec["lc"], 3)
|
self.assertEqual(filterspec["lc"], 3)
|
||||||
self.assertEqual(filterspec["dict_size"], 8 << 20)
|
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):
|
def test_filter_properties_roundtrip(self):
|
||||||
spec1 = lzma._decode_filter_properties(
|
spec1 = lzma._decode_filter_properties(
|
||||||
lzma.FILTER_LZMA1, b"]\x00\x00\x80\x00")
|
lzma.FILTER_LZMA1, b"]\x00\x00\x80\x00")
|
||||||
|
|
|
@ -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.
|
|
@ -494,7 +494,9 @@ build_filter_spec(const lzma_filter *f)
|
||||||
case LZMA_FILTER_ARMTHUMB:
|
case LZMA_FILTER_ARMTHUMB:
|
||||||
case LZMA_FILTER_SPARC: {
|
case LZMA_FILTER_SPARC: {
|
||||||
lzma_options_bcj *options = f->options;
|
lzma_options_bcj *options = f->options;
|
||||||
ADD_FIELD(options, start_offset);
|
if (options) {
|
||||||
|
ADD_FIELD(options, start_offset);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue