-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ext/gd: calls with array types check strengthening. #18005
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like adding a common function php_gd_zval_try_get_c_int()
seems like a good idea.
ext/gd/gd.c
Outdated
} | ||
stylearr[index++] = tmp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't there a possibility of int
under/overflow ?
ext/gd/gd.c
Outdated
@@ -3840,28 +3862,48 @@ PHP_FUNCTION(imagecrop) | |||
im = php_gd_libgdimageptr_from_zval_p(IM); | |||
|
|||
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "x", sizeof("x") -1)) != NULL) { | |||
rect.x = zval_get_long(tmp); | |||
r = zval_get_long(tmp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try get long?
ext/gd/gd.c
Outdated
} else { | ||
zend_argument_value_error(2, "must have an \"x\" key"); | ||
RETURN_THROWS(); | ||
} | ||
|
||
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "y", sizeof("y") - 1)) != NULL) { | ||
rect.y = zval_get_long(tmp); | ||
r = zval_get_long(tmp); | ||
if (ZEND_LONG_EXCEEDS_INT(r)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try get long?
ext/gd/gd.c
Outdated
} else { | ||
zend_argument_value_error(2, "must have a \"y\" key"); | ||
RETURN_THROWS(); | ||
} | ||
|
||
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "width", sizeof("width") - 1)) != NULL) { | ||
rect.width = zval_get_long(tmp); | ||
r = zval_get_long(tmp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
ext/gd/gd.c
Outdated
} else { | ||
zend_argument_value_error(2, "must have a \"width\" key"); | ||
RETURN_THROWS(); | ||
} | ||
|
||
if ((tmp = zend_hash_str_find(Z_ARRVAL_P(z_rect), "height", sizeof("height") - 1)) != NULL) { | ||
rect.height = zval_get_long(tmp); | ||
r = zval_get_long(tmp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto?
bea99f9
to
3233235
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally makes sense to me, maybe @cmb69 wants to have a look?
@@ -3822,6 +3848,22 @@ PHP_FUNCTION(imageantialias) | |||
} | |||
/* }}} */ | |||
|
|||
static bool _php_gd_zval_try_get_c_int(zval *tmp, const char *field, int *res) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Symbols starting with _
are reserved in C, so please avoid this.
static bool _php_gd_zval_try_get_c_int(zval *tmp, const char *field, int *res) { | |
static bool php_gd_zval_try_get_c_int(zval *tmp, const char *field, int *res) { |
No description provided.