summaryrefslogtreecommitdiff
path: root/ext/gd/libgd
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2019-01-06 11:57:16 -0800
committerStanislav Malyshev <stas@php.net>2019-01-06 11:57:16 -0800
commitfe820fcba616a736b80e911cfc132388acd35ace (patch)
treed958a1c3d69c8089081a807f4fb8cdfa80007422 /ext/gd/libgd
parent41af1e6781386cf540926ba9d1ff59a3402f8e01 (diff)
parent8d3dfabef459fe7815e8ea2fd68753fd17859d7b (diff)
downloadphp-git-fe820fcba616a736b80e911cfc132388acd35ace.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fix #77369 - memcpy with negative length via crafted DNS response Fix more issues with encodilng length Fix #77270: imagecolormatch Out Of Bounds Write on Heap Fix bug #77380 (Global out of bounds read in xmlrpc base64 code) Fix bug #77371 (heap buffer overflow in mb regex functions - compile_string_node) Fix bug #77370 - check that we do not read past buffer end when parsing multibytes Fix #77269: Potential unsigned underflow in gdImageScale Fix bug #77247 (heap buffer overflow in phar_detect_phar_fname_ext) Fix bug #77242 (heap out of bounds read in xmlrpc_decode()) Regenerate certs for openssl tests
Diffstat (limited to 'ext/gd/libgd')
-rw-r--r--ext/gd/libgd/gd_color_match.c4
-rw-r--r--ext/gd/libgd/gd_interpolation.c18
2 files changed, 11 insertions, 11 deletions
diff --git a/ext/gd/libgd/gd_color_match.c b/ext/gd/libgd/gd_color_match.c
index a4e56b1c40..e6f539bc75 100644
--- a/ext/gd/libgd/gd_color_match.c
+++ b/ext/gd/libgd/gd_color_match.c
@@ -33,8 +33,8 @@ int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
return -4; /* At least 1 color must be allocated */
}
- buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
- memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
+ buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * gdMaxColors, 0);
+ memset( buf, 0, sizeof(unsigned long) * 5 * gdMaxColors );
for (x=0; x<im1->sx; x++) {
for( y=0; y<im1->sy; y++ ) {
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c
index 2a2479c912..e3cd741f8a 100644
--- a/ext/gd/libgd/gd_interpolation.c
+++ b/ext/gd/libgd/gd_interpolation.c
@@ -890,8 +890,13 @@ static inline LineContribType * _gdContributionsAlloc(unsigned int line_length,
{
unsigned int u = 0;
LineContribType *res;
- int overflow_error = 0;
+ size_t weights_size;
+ if (overflow2(windows_size, sizeof(double))) {
+ return NULL;
+ } else {
+ weights_size = windows_size * sizeof(double);
+ }
res = (LineContribType *) gdMalloc(sizeof(LineContribType));
if (!res) {
return NULL;
@@ -908,15 +913,10 @@ static inline LineContribType * _gdContributionsAlloc(unsigned int line_length,
return NULL;
}
for (u = 0 ; u < line_length ; u++) {
- if (overflow2(windows_size, sizeof(double))) {
- overflow_error = 1;
- } else {
- res->ContribRow[u].Weights = (double *) gdMalloc(windows_size * sizeof(double));
- }
- if (overflow_error == 1 || res->ContribRow[u].Weights == NULL) {
+ res->ContribRow[u].Weights = (double *) gdMalloc(weights_size);
+ if (res->ContribRow[u].Weights == NULL) {
unsigned int i;
- u--;
- for (i=0;i<=u;i++) {
+ for (i=0;i<u;i++) {
gdFree(res->ContribRow[i].Weights);
}
gdFree(res->ContribRow);