diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-27 20:23:41 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-09-27 20:23:41 +0300 |
commit | a12e7842a5f572afd6bde108f24931f9262f38ef (patch) | |
tree | a7bd0d9db6ec6a3c16cff1e2ac3a343a230dadd6 | |
parent | 19f2327e7ee3cc307b8b59329c552583d29ffa57 (diff) | |
parent | c0b7037d4fc0f85af858cfa56df4dca25fb8896f (diff) | |
download | cpython-git-a12e7842a5f572afd6bde108f24931f9262f38ef.tar.gz |
Issue #28275: Fixed possible use adter free in LZMADecompressor.decompress().
Original patch by John Leitch.
-rw-r--r-- | Lib/test/test_lzma.py | 9 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Modules/_lzmamodule.c | 4 |
3 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_lzma.py b/Lib/test/test_lzma.py index d310bea2b1..77ca022f45 100644 --- a/Lib/test/test_lzma.py +++ b/Lib/test/test_lzma.py @@ -246,6 +246,15 @@ class CompressorDecompressorTestCase(unittest.TestCase): lzd = LZMADecompressor(lzma.FORMAT_RAW, filters=FILTERS_RAW_1) self.assertRaises(LZMAError, lzd.decompress, COMPRESSED_XZ) + def test_decompressor_bug_28275(self): + # Test coverage for Issue 28275 + lzd = LZMADecompressor() + for i in range(2): + try: + lzd.decompress(COMPRESSED_RAW_1) + except LZMAError: + pass + # Test that LZMACompressor->LZMADecompressor preserves the input data. def test_roundtrip_xz(self): @@ -41,6 +41,9 @@ Core and Builtins Library ------- +- Issue #28275: Fixed possible use adter free in LZMADecompressor.decompress(). + Original patch by John Leitch. + - Issue #27897: Fixed possible crash in sqlite3.Connection.create_collation() if pass invalid string-like object as a name. Patch by Xiang Zhang. diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c index 5e158fd07d..f5dcea19f1 100644 --- a/Modules/_lzmamodule.c +++ b/Modules/_lzmamodule.c @@ -995,8 +995,10 @@ decompress(Decompressor *d, uint8_t *data, size_t len, Py_ssize_t max_length) } result = decompress_buf(d, max_length); - if(result == NULL) + if (result == NULL) { + lzs->next_in = NULL; return NULL; + } if (d->eof) { d->needs_input = 0; |