File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -4282,12 +4282,28 @@ PHP_FUNCTION(imageresolution)
4282
4282
im = php_gd_libgdimageptr_from_zval_p (IM );
4283
4283
4284
4284
if (!res_x_is_null && !res_y_is_null ) {
4285
+ if (res_x < 0 || ZEND_SIZE_T_UINT_OVFL (res_x )) {
4286
+ zend_argument_value_error (2 , "must be between 0 and %u" , UINT_MAX );
4287
+ RETURN_THROWS ();
4288
+ }
4289
+ if (res_y < 0 || ZEND_SIZE_T_UINT_OVFL (res_y )) {
4290
+ zend_argument_value_error (3 , "must be between 0 and %u" , UINT_MAX );
4291
+ RETURN_THROWS ();
4292
+ }
4285
4293
gdImageSetResolution (im , res_x , res_y );
4286
4294
RETURN_TRUE ;
4287
4295
} else if (!res_x_is_null && res_y_is_null ) {
4296
+ if (res_x < 0 || ZEND_SIZE_T_UINT_OVFL (res_x )) {
4297
+ zend_argument_value_error (2 , "must be between 0 and %u" , UINT_MAX );
4298
+ RETURN_THROWS ();
4299
+ }
4288
4300
gdImageSetResolution (im , res_x , res_x );
4289
4301
RETURN_TRUE ;
4290
4302
} else if (res_x_is_null && !res_y_is_null ) {
4303
+ if (res_y < 0 || ZEND_SIZE_T_UINT_OVFL (res_y )) {
4304
+ zend_argument_value_error (3 , "must be between 0 and %u" , UINT_MAX );
4305
+ RETURN_THROWS ();
4306
+ }
4291
4307
gdImageSetResolution (im , res_y , res_y );
4292
4308
RETURN_TRUE ;
4293
4309
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Wrong image resolution
3
+ --EXTENSIONS--
4
+ gd
5
+ --SKIPIF--
6
+ <?php
7
+ if (PHP_INT_SIZE != 8 ) die ("skip on non 64 bits architectures " );
8
+ ?>
9
+ --FILE--
10
+ <?php
11
+ $ filename = __DIR__ . DIRECTORY_SEPARATOR . 'imageresolution_png.png ' ;
12
+
13
+ $ exp = imagecreate (100 , 100 );
14
+ imagecolorallocate ($ exp , 255 , 127 , 64 );
15
+
16
+ $ res = imageresolution ($ exp );
17
+
18
+ try {
19
+ imageresolution ($ exp , PHP_INT_MAX );
20
+ } catch (\ValueError $ e ) {
21
+ echo $ e ->getMessage () . PHP_EOL ;
22
+ }
23
+ try {
24
+ imageresolution ($ exp , 127 , -PHP_INT_MAX );
25
+ } catch (\ValueError $ e ) {
26
+ echo $ e ->getMessage () . PHP_EOL ;
27
+ }
28
+ imageresolution ($ exp , 0 , 0 );
29
+ var_dump (imageresolution ($ exp ) == $ res );
30
+ ?>
31
+ --EXPECTF--
32
+ imageresolution(): Argument #2 ($resolution_x) must be between 0 and %d
33
+ imageresolution(): Argument #3 ($resolution_y) must be between 0 and %d
34
+ bool(true)
You can’t perform that action at this time.
0 commit comments