diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2018-11-24 12:56:43 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2018-11-24 12:57:44 +0100 |
commit | caabf3a1bbddca8c467ee9733450153ce2ab6cef (patch) | |
tree | b08a3fb9890e646fdcf9e9f9f4610c542f2b3e0d /ext/gd | |
parent | 2979c6a56ddcf45113dd30ca3ed90880dfabc972 (diff) | |
parent | 60a9f7a3a3502bfb7118f7fc5c06f9fdf713efad (diff) | |
download | php-git-caabf3a1bbddca8c467ee9733450153ce2ab6cef.tar.gz |
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
Fix #77195: Incorrect error handling of imagecreatefromjpeg()
Diffstat (limited to 'ext/gd')
-rw-r--r-- | ext/gd/libgd/gd_jpeg.c | 13 | ||||
-rw-r--r-- | ext/gd/tests/bug77195.jpeg | bin | 0 -> 1038 bytes | |||
-rw-r--r-- | ext/gd/tests/bug77195.phpt | 19 |
3 files changed, 28 insertions, 4 deletions
diff --git a/ext/gd/libgd/gd_jpeg.c b/ext/gd/libgd/gd_jpeg.c index 6d97cc7bc0..8cf71fcbc9 100644 --- a/ext/gd/libgd/gd_jpeg.c +++ b/ext/gd/libgd/gd_jpeg.c @@ -67,14 +67,18 @@ static long php_jpeg_emit_message(j_common_ptr jpeg_info, int level) * unless strace_level >= 3 */ if ((jpeg_info->err->num_warnings == 0) || (jpeg_info->err->trace_level >= 3)) { - gd_error_ex(ignore_warning ? GD_NOTICE : GD_WARNING, "gd-jpeg, libjpeg: recoverable error: %s\n", message); + if (!ignore_warning) { + gd_error("gd-jpeg, libjpeg: recoverable error: %s\n", message); + } } jpeg_info->err->num_warnings++; } else { /* strace msg, Show it if trace_level >= level. */ if (jpeg_info->err->trace_level >= level) { - gd_error_ex(GD_NOTICE, "gd-jpeg, libjpeg: strace message: %s\n", message); + if (!ignore_warning) { + gd_error("gd-jpeg, libjpeg: strace message: %s\n", message); + } } } return 1; @@ -86,9 +90,10 @@ static long php_jpeg_emit_message(j_common_ptr jpeg_info, int level) static void fatal_jpeg_error (j_common_ptr cinfo) { jmpbuf_wrapper *jmpbufw; + char buffer[JMSG_LENGTH_MAX]; - gd_error("gd-jpeg: JPEG library reports unrecoverable error: "); - (*cinfo->err->output_message) (cinfo); + (*cinfo->err->format_message)(cinfo, buffer); + gd_error_ex(GD_WARNING, "gd-jpeg: JPEG library reports unrecoverable error: %s", buffer); jmpbufw = (jmpbuf_wrapper *) cinfo->client_data; jpeg_destroy (cinfo); diff --git a/ext/gd/tests/bug77195.jpeg b/ext/gd/tests/bug77195.jpeg Binary files differnew file mode 100644 index 0000000000..66f92cf946 --- /dev/null +++ b/ext/gd/tests/bug77195.jpeg diff --git a/ext/gd/tests/bug77195.phpt b/ext/gd/tests/bug77195.phpt new file mode 100644 index 0000000000..944a09fc1a --- /dev/null +++ b/ext/gd/tests/bug77195.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #77195 (Incorrect error handling of imagecreatefromjpeg()) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +if (!gd_info()['JPEG Support']) die('skip JPEG support not available'); +?> +--FILE-- +<?php +$filename = __DIR__ . '/bug77195.jpeg'; +@imagecreatefromjpeg($filename); +imagecreatefromjpeg($filename); +?> +===DONE=== +--EXPECTF-- +Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: JPEG datastream contains no image in %s on line %d + +Warning: imagecreatefromjpeg(): '/mnt/c/Users/cmb/php-dev/php-src/ext/gd/tests/bug77195.jpeg' is not a valid JPEG file in %s on line %d +===DONE=== |