mirror of
https://github.com/python/cpython.git
synced 2026-06-27 19:36:07 +00:00
[3.11] gh-148395: Fix a possible UAF in {LZMA,BZ2}Decompressor (GH-148396) (#148504)
Fix dangling input pointer after `MemoryError` in _lzma/_bz2/_ZlibDecompressor.decompress
(cherry picked from commit 8fc66aef6d)
This commit is contained in:
parent
f4654824ae
commit
e20c6c9667
3 changed files with 7 additions and 0 deletions
|
|
@ -0,0 +1,5 @@
|
|||
Fix a dangling input pointer in :class:`lzma.LZMADecompressor`,
|
||||
and :class:`bz2.BZ2Decompressor`
|
||||
when memory allocation fails with :exc:`MemoryError`, which could let a
|
||||
subsequent :meth:`!decompress` call read or write through a stale pointer to
|
||||
the already-released caller buffer.
|
||||
|
|
@ -595,6 +595,7 @@ decompress(BZ2Decompressor *d, char *data, size_t len, Py_ssize_t max_length)
|
|||
return result;
|
||||
|
||||
error:
|
||||
bzs->next_in = NULL;
|
||||
Py_XDECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1105,6 +1105,7 @@ decompress(Decompressor *d, uint8_t *data, size_t len, Py_ssize_t max_length)
|
|||
return result;
|
||||
|
||||
error:
|
||||
lzs->next_in = NULL;
|
||||
Py_XDECREF(result);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue