mirror of
https://github.com/python-pillow/Pillow.git
synced 2026-02-21 22:50:28 +03:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5158d98c80 | ||
|
|
9000313cc5 | ||
|
|
cd0111849f |
BIN
Tests/images/psd-oob-write-x.psd
Normal file
BIN
Tests/images/psd-oob-write-x.psd
Normal file
Binary file not shown.
BIN
Tests/images/psd-oob-write-y.psd
Normal file
BIN
Tests/images/psd-oob-write-y.psd
Normal file
Binary file not shown.
BIN
Tests/images/psd-oob-write.psd
Normal file
BIN
Tests/images/psd-oob-write.psd
Normal file
Binary file not shown.
|
|
@ -184,3 +184,20 @@ def test_layer_crashes(test_file: str) -> None:
|
||||||
assert isinstance(im, PsdImagePlugin.PsdImageFile)
|
assert isinstance(im, PsdImagePlugin.PsdImageFile)
|
||||||
with pytest.raises(SyntaxError):
|
with pytest.raises(SyntaxError):
|
||||||
im.layers
|
im.layers
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"test_file",
|
||||||
|
[
|
||||||
|
"Tests/images/psd-oob-write.psd",
|
||||||
|
"Tests/images/psd-oob-write-x.psd",
|
||||||
|
"Tests/images/psd-oob-write-y.psd",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_bounds_crash(test_file: str) -> None:
|
||||||
|
with Image.open(test_file) as im:
|
||||||
|
assert isinstance(im, PsdImagePlugin.PsdImageFile)
|
||||||
|
im.seek(im.n_frames)
|
||||||
|
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
im.load()
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,13 @@ class TestImageFile:
|
||||||
with pytest.raises(ValueError, match="Tile offset cannot be negative"):
|
with pytest.raises(ValueError, match="Tile offset cannot be negative"):
|
||||||
im.load()
|
im.load()
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("xy", ((-1, 0), (0, -1)))
|
||||||
|
def test_negative_tile_extents(self, xy: tuple[int, int]) -> None:
|
||||||
|
im = Image.new("1", (1, 1))
|
||||||
|
fp = BytesIO()
|
||||||
|
with pytest.raises(SystemError, match="tile cannot extend outside image"):
|
||||||
|
ImageFile._save(im, fp, [ImageFile._Tile("raw", xy + (1, 1), 0, "1")])
|
||||||
|
|
||||||
def test_no_format(self) -> None:
|
def test_no_format(self) -> None:
|
||||||
buf = BytesIO(b"\x00" * 255)
|
buf = BytesIO(b"\x00" * 255)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,10 @@ version=1.3.0
|
||||||
|
|
||||||
pushd libavif-$version
|
pushd libavif-$version
|
||||||
|
|
||||||
|
# Apply patch for SVT-AV1 4.0 compatibility
|
||||||
|
# Pending release of https://github.com/AOMediaCodec/libavif/pull/2971
|
||||||
|
patch -p1 < ../libavif-svt4.patch
|
||||||
|
|
||||||
if [ $(uname) == "Darwin" ] && [ -x "$(command -v brew)" ]; then
|
if [ $(uname) == "Darwin" ] && [ -x "$(command -v brew)" ]; then
|
||||||
PREFIX=$(brew --prefix)
|
PREFIX=$(brew --prefix)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
14
depends/libavif-svt4.patch
Normal file
14
depends/libavif-svt4.patch
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
--- a/src/codec_svt.c
|
||||||
|
+++ b/src/codec_svt.c
|
||||||
|
@@ -162,7 +162,11 @@ static avifResult svtCodecEncodeImage(avifEncoder * encoder,
|
||||||
|
#else
|
||||||
|
svt_config->logical_processors = encoder->maxThreads;
|
||||||
|
#endif
|
||||||
|
+#if SVT_AV1_CHECK_VERSION(4, 0, 0)
|
||||||
|
+ svt_config->aq_mode = 2;
|
||||||
|
+#else
|
||||||
|
svt_config->enable_adaptive_quantization = 2;
|
||||||
|
+#endif
|
||||||
|
// disable 2-pass
|
||||||
|
#if SVT_AV1_CHECK_VERSION(0, 9, 0)
|
||||||
|
svt_config->rc_stats_buffer = (SvtAv1FixedBuf) { NULL, 0 };
|
||||||
24
docs/releasenotes/12.1.1.rst
Normal file
24
docs/releasenotes/12.1.1.rst
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
12.1.1
|
||||||
|
------
|
||||||
|
|
||||||
|
Security
|
||||||
|
========
|
||||||
|
|
||||||
|
:cve:`2021-25289`: Fix OOB write with invalid tile extents
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Check that tile extents do not use negative x or y offsets when decoding or encoding,
|
||||||
|
and raise an error if they do, rather than allowing an OOB write.
|
||||||
|
|
||||||
|
An out-of-bounds write may be triggered when opening a specially crafted PSD image.
|
||||||
|
This only affects Pillow >= 10.3.0. Reported by
|
||||||
|
`Yarden Porat <https://github.com/yardenporat353>`__.
|
||||||
|
|
||||||
|
Other changes
|
||||||
|
=============
|
||||||
|
|
||||||
|
Patch libavif for svt-av1 4.0 compatibility
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
A patch has been added to ``depends/install_libavif.sh``, to allow libavif 1.3.0 to be
|
||||||
|
compatible with the recently released svt-av1 4.0.0.
|
||||||
|
|
@ -15,6 +15,7 @@ expected to be backported to earlier versions.
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
versioning
|
versioning
|
||||||
|
12.1.1
|
||||||
12.1.0
|
12.1.0
|
||||||
12.0.0
|
12.0.0
|
||||||
11.3.0
|
11.3.0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Master version for Pillow
|
# Master version for Pillow
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
__version__ = "12.1.0"
|
__version__ = "12.1.1"
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,8 @@ _setimage(ImagingDecoderObject *decoder, PyObject *args) {
|
||||||
state->ysize = y1 - y0;
|
state->ysize = y1 - y0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->xsize <= 0 || state->xsize + state->xoff > (int)im->xsize ||
|
if (state->xoff < 0 || state->xsize <= 0 ||
|
||||||
|
state->xsize + state->xoff > (int)im->xsize || state->yoff < 0 ||
|
||||||
state->ysize <= 0 || state->ysize + state->yoff > (int)im->ysize) {
|
state->ysize <= 0 || state->ysize + state->yoff > (int)im->ysize) {
|
||||||
PyErr_SetString(PyExc_ValueError, "tile cannot extend outside image");
|
PyErr_SetString(PyExc_ValueError, "tile cannot extend outside image");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
|
|
@ -254,7 +254,8 @@ _setimage(ImagingEncoderObject *encoder, PyObject *args) {
|
||||||
state->ysize = y1 - y0;
|
state->ysize = y1 - y0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->xsize <= 0 || state->xsize + state->xoff > im->xsize ||
|
if (state->xoff < 0 || state->xsize <= 0 ||
|
||||||
|
state->xsize + state->xoff > im->xsize || state->yoff < 0 ||
|
||||||
state->ysize <= 0 || state->ysize + state->yoff > im->ysize) {
|
state->ysize <= 0 || state->ysize + state->yoff > im->ysize) {
|
||||||
PyErr_SetString(PyExc_SystemError, "tile cannot extend outside image");
|
PyErr_SetString(PyExc_SystemError, "tile cannot extend outside image");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user