File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ PHP NEWS
3131- GD:
3232 . Fixed bug GH-20511 (imagegammacorrect out of range input/output values).
3333 (David Carlier)
34+ . Fixed bug GH-20602 (imagescale overflow with large height values).
35+ (David Carlier)
3436
3537- LibXML:
3638 . Fix some deprecations on newer libxml versions regarding input
Original file line number Diff line number Diff line change @@ -4042,9 +4042,17 @@ PHP_FUNCTION(imagescale)
40424042 src_y = gdImageSY (im );
40434043
40444044 if (src_x && tmp_h < 0 ) {
4045+ if (tmp_w > (ZEND_LONG_MAX / src_y )) {
4046+ zend_argument_value_error (2 , "must be less than or equal to " ZEND_LONG_FMT , (zend_long )(ZEND_LONG_MAX / src_y ));
4047+ RETURN_THROWS ();
4048+ }
40454049 tmp_h = tmp_w * src_y / src_x ;
40464050 }
40474051 if (src_y && tmp_w < 0 ) {
4052+ if (tmp_h > (ZEND_LONG_MAX / src_x )) {
4053+ zend_argument_value_error (3 , "must be less than or equal to " ZEND_LONG_FMT , (zend_long )(ZEND_LONG_MAX / src_x ));
4054+ RETURN_THROWS ();
4055+ }
40484056 tmp_w = tmp_h * src_x / src_y ;
40494057 }
40504058 }
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-20551: (imagegammacorrect out of range input/output value)
3+ --EXTENSIONS--
4+ gd
5+ --FILE--
6+ <?php
7+ $ im = imagecreatetruecolor (16 , 16 );
8+
9+ try {
10+ imagescale ($ im , PHP_INT_MAX , -1 );
11+ } catch (\ValueError $ e ) {
12+ echo $ e ->getMessage (), PHP_EOL ;
13+ }
14+ try {
15+ imagescale ($ im , -1 , PHP_INT_MAX );
16+ } catch (\ValueError $ e ) {
17+ echo $ e ->getMessage (), PHP_EOL ;
18+ }
19+ ?>
20+ --EXPECTF--
21+ imagescale(): Argument #2 ($width) must be less than or equal to %d
22+ imagescale(): Argument #3 ($height) must be less than or equal to %d
You can’t perform that action at this time.
0 commit comments