File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -3931,9 +3931,17 @@ PHP_FUNCTION(imagescale)
39313931 src_y = gdImageSY (im );
39323932
39333933 if (src_x && tmp_h < 0 ) {
3934+ if (tmp_w > (ZEND_LONG_MAX / src_y )) {
3935+ zend_argument_value_error (2 , "must be less than or equal to " ZEND_LONG_FMT , (zend_long )(ZEND_LONG_MAX / src_y ));
3936+ RETURN_THROWS ();
3937+ }
39343938 tmp_h = tmp_w * src_y / src_x ;
39353939 }
39363940 if (src_y && tmp_w < 0 ) {
3941+ if (tmp_h > (ZEND_LONG_MAX / src_x )) {
3942+ zend_argument_value_error (3 , "must be less than or equal to " ZEND_LONG_FMT , (zend_long )(ZEND_LONG_MAX / src_x ));
3943+ RETURN_THROWS ();
3944+ }
39373945 tmp_w = tmp_h * src_x / src_y ;
39383946 }
39393947 }
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