Skip to content

Commit

Permalink
Limit argument processing and add error handling
Browse files Browse the repository at this point in the history
Introduce an upper limit of 16 for argument processing to prevent potential issues during execution. Added error handling to manage cases where adding a parameter to the array fails, ensuring a more robust execution of the function.
  • Loading branch information
koriym committed Dec 9, 2024
1 parent 3d5abd3 commit 0cfca25
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rayaop.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,16 @@ static void rayaop_execute_ex(zend_execute_data *execute_data) {
uint32_t arg_count = ZEND_CALL_NUM_ARGS(execute_data);
if (arg_count > 0 && !EG(exception)) {
zval *args = ZEND_CALL_ARG(execute_data, 1);
if (args && !EG(exception)) {
for (uint32_t i = 0; i < arg_count; i++) {
if (args) {
for (uint32_t i = 0; i < arg_count && i < 16; i++) { // 上限を設定
zval *arg = &args[i];
if (!Z_ISUNDEF_P(arg)) {
Z_TRY_ADDREF_P(arg);
add_next_index_zval(&params[2], arg);
if (add_next_index_zval(&params[2], arg) != SUCCESS) {
// エラー処理を追加
php_rayaop_handle_error(RAYAOP_E_INVALID_STATE, "Failed to add parameter to array");
break;
}
}
}
}
Expand Down

0 comments on commit 0cfca25

Please sign in to comment.