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 @@ -27,6 +27,8 @@ PHP NEWS
2727- GD:
2828 . Fixed bug GH-20511 (imagegammacorrect out of range input/output values).
2929 (David Carlier)
30+ . Fixed bug GH-20602 (imagescale overflow with large height values).
31+ (David Carlier)
3032
3133- LibXML:
3234 . Fix some deprecations on newer libxml versions regarding input
Original file line number Diff line number Diff line change @@ -3689,9 +3689,17 @@ PHP_FUNCTION(imagescale)
36893689 src_y = gdImageSY (im );
36903690
36913691 if (src_x && tmp_h < 0 ) {
3692+ if (tmp_w > (ZEND_LONG_MAX / src_y )) {
3693+ zend_argument_value_error (2 , "must be less than or equal to " ZEND_LONG_FMT , (zend_long )(ZEND_LONG_MAX / src_y ));
3694+ RETURN_THROWS ();
3695+ }
36923696 tmp_h = tmp_w * src_y / src_x ;
36933697 }
36943698 if (src_y && tmp_w < 0 ) {
3699+ if (tmp_h > (ZEND_LONG_MAX / src_x )) {
3700+ zend_argument_value_error (3 , "must be less than or equal to " ZEND_LONG_FMT , (zend_long )(ZEND_LONG_MAX / src_x ));
3701+ RETURN_THROWS ();
3702+ }
36953703 tmp_w = tmp_h * src_x / src_y ;
36963704 }
36973705 }
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