Skip to content

Commit 57cb01a

Browse files
committed
Properly check imagegd() signature
Unlike imagegd2(), this function only accepts two parameters, so we should be checking for that.
1 parent 838ae01 commit 57cb01a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ext/gd/gd.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,8 +1785,18 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
17851785

17861786
/* The quality parameter for gd2 stands for chunk size */
17871787

1788-
if (zend_parse_parameters(argc, "O|p!ll", &imgind, gd_image_ce, &file, &file_len, &quality, &type) == FAILURE) {
1789-
RETURN_THROWS();
1788+
switch (image_type) {
1789+
case PHP_GDIMG_TYPE_GD:
1790+
if (zend_parse_parameters(argc, "O|p!", &imgind, gd_image_ce, &file, &file_len) == FAILURE) {
1791+
RETURN_THROWS();
1792+
}
1793+
break;
1794+
case PHP_GDIMG_TYPE_GD2:
1795+
if (zend_parse_parameters(argc, "O|p!ll", &imgind, gd_image_ce, &file, &file_len, &quality, &type) == FAILURE) {
1796+
RETURN_THROWS();
1797+
}
1798+
break;
1799+
EMPTY_SWITCH_DEFAULT_CASE()
17901800
}
17911801

17921802
im = php_gd_libgdimageptr_from_zval_p(imgind);

0 commit comments

Comments
 (0)