Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to avoid CVE-2021-34552, CVE-2021-25287, CVE-2021-25288, CVE-2020-10994 #1

Merged
merged 10 commits into from Jul 28, 2021
6 changes: 6 additions & 0 deletions j5_build_instructions.txt
@@ -0,0 +1,6 @@
Follow the steps in winbuild.rst with the following adustments:
1. If the downloading of the dependencies fails, adjust the requests call to add header to stop it getting blocked as a blob.
3. Install Visual Studio C++ extension for 9.0, 10.0, 12.0 and 14.0 (TBC which are actually required)
5. After running `build_deps.py`, which will fail, - adjust build-deps.cmd batch script with the following:
- add "set VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\4.0\V140" on line 14
- change "v7.0" to "v7.1" on line 26 (now 27) for the SetEnv.cmd file
2 changes: 1 addition & 1 deletion src/PIL/_version.py
@@ -1,2 +1,2 @@
# Master version for Pillow
__version__ = "6.2.2"
__version__ = "6.2.2+j5"
19 changes: 11 additions & 8 deletions src/libImaging/Convert.c
Expand Up @@ -1623,10 +1623,9 @@ convert(Imaging imOut, Imaging imIn, const char *mode,
return (Imaging) ImagingError_ValueError("conversion not supported");
#else
{
static char buf[256];
/* FIXME: may overflow if mode is too large */
sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode);
return (Imaging) ImagingError_ValueError(buf);
static char buf[100];
snprintf(buf, 100, "conversion from %.10s to %.10s not supported", imIn->mode, mode);
return (Imaging)ImagingError_ValueError(buf);
}
#endif

Expand Down Expand Up @@ -1681,10 +1680,14 @@ ImagingConvertTransparent(Imaging imIn, const char *mode,
}
#else
{
static char buf[256];
/* FIXME: may overflow if mode is too large */
sprintf(buf, "conversion from %s to %s not supported in convert_transparent", imIn->mode, mode);
return (Imaging) ImagingError_ValueError(buf);
static char buf[100];
snprintf(
buf,
100,
"conversion from %.10s to %.10s not supported in convert_transparent",
imIn->mode,
mode);
return (Imaging)ImagingError_ValueError(buf);
}
#endif

Expand Down
17 changes: 2 additions & 15 deletions winbuild/build.py 100755 → 100644
Expand Up @@ -111,9 +111,9 @@ def build_one(py_ver, compiler, bit):
args["tcl_ver"] = "86"

if compiler["vc_version"] == "2015":
args["imaging_libs"] = " build_ext --add-imaging-libs=msvcrt"
args["imaging_libs"] = " build_ext --disable-jpeg2000 --add-imaging-libs=msvcrt"
else:
args["imaging_libs"] = ""
args["imaging_libs"] = "build_ext --disable-jpeg2000"

args["vc_setup"] = vc_setup(compiler, bit)

Expand Down Expand Up @@ -158,19 +158,6 @@ def main(op):
)
)

scripts.append(
(
"%s%s" % (py_version, X64_EXT),
"\n".join(
[
header(op),
build_one("%sx64" % py_version, py_compilers[64], 64),
footer(),
]
),
)
)

results = map(run_script, scripts)

for (version, status, trace, err) in results:
Expand Down
26 changes: 13 additions & 13 deletions winbuild/config.py
@@ -1,16 +1,16 @@
import os

SF_MIRROR = "http://iweb.dl.sourceforge.net"
PILLOW_DEPENDS_DIR = "C:\\pillow-depends\\"
GITHUB_DEPENDS_URL = "https://github.com/python-pillow/pillow-depends/blob/master/"

pythons = {
"27": {"compiler": 7, "vc": 2010},
"pypy2": {"compiler": 7, "vc": 2010},
"35": {"compiler": 7.1, "vc": 2015},
"36": {"compiler": 7.1, "vc": 2015},
"pypy3": {"compiler": 7.1, "vc": 2015},
"37": {"compiler": 7.1, "vc": 2015},
"38": {"compiler": 7.1, "vc": 2015},
# "pypy2": {"compiler": 7, "vc": 2010},
# "35": {"compiler": 7.1, "vc": 2015},
# "36": {"compiler": 7.1, "vc": 2015},
# "pypy3": {"compiler": 7.1, "vc": 2015},
# "37": {"compiler": 7.1, "vc": 2015},
# "38": {"compiler": 7.1, "vc": 2015},
}

VIRT_BASE = "c:/vp/"
Expand All @@ -32,7 +32,7 @@
"dir": "jpeg-9c",
},
"tiff": {
"url": "ftp://download.osgeo.org/libtiff/tiff-4.0.10.tar.gz",
"url": "https://download.osgeo.org/libtiff/tiff-4.0.10.tar.gz",
"filename": PILLOW_DEPENDS_DIR + "tiff-4.0.10.tar.gz",
"dir": "tiff-4.0.10",
},
Expand All @@ -42,7 +42,7 @@
"dir": "freetype-2.10.1",
},
"lcms": {
"url": SF_MIRROR + "/project/lcms/lcms/2.7/lcms2-2.7.zip",
"url": GITHUB_DEPENDS_URL + "lcms2-2.7.zip",
"filename": PILLOW_DEPENDS_DIR + "lcms2-2.7.zip",
"dir": "lcms2-2.7",
},
Expand All @@ -52,23 +52,23 @@
"dir": "ghostscript-9.27",
},
"tcl-8.5": {
"url": SF_MIRROR + "/project/tcl/Tcl/8.5.19/tcl8519-src.zip",
"url": GITHUB_DEPENDS_URL + "tcl8519-src.zip",
"filename": PILLOW_DEPENDS_DIR + "tcl8519-src.zip",
"dir": "",
},
"tk-8.5": {
"url": SF_MIRROR + "/project/tcl/Tcl/8.5.19/tk8519-src.zip",
"url": GITHUB_DEPENDS_URL + "tk8519-src.zip",
"filename": PILLOW_DEPENDS_DIR + "tk8519-src.zip",
"dir": "",
"version": "8.5.19",
},
"tcl-8.6": {
"url": SF_MIRROR + "/project/tcl/Tcl/8.6.9/tcl869-src.zip",
"url": GITHUB_DEPENDS_URL + "tcl869-src.zip",
"filename": PILLOW_DEPENDS_DIR + "tcl869-src.zip",
"dir": "",
},
"tk-8.6": {
"url": SF_MIRROR + "/project/tcl/Tcl/8.6.9/tk869-src.zip",
"url": GITHUB_DEPENDS_URL + "tk869-src.zip",
"filename": PILLOW_DEPENDS_DIR + "tk869-src.zip",
"dir": "",
"version": "8.6.9",
Expand Down