Skip to content

Commit

Permalink
Check for spprintf failure in key generation
Browse files Browse the repository at this point in the history
Add a check for negative length returned by spprintf to ensure key generation doesn't proceed with invalid data. This prevents potential issues or crashes that could occur if the function fails and returns an error.
  • Loading branch information
koriym committed Dec 9, 2024
1 parent 3344101 commit dea7e8e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rayaop.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ PHP_RAYAOP_API char *php_rayaop_generate_key(zend_string *class_name, zend_strin
}
char *key;
int len = spprintf(&key, 0, "%s::%s", ZSTR_VAL(class_name), ZSTR_VAL(method_name));
if (len < 0) {
return NULL;
}
if (key_len) {
*key_len = (size_t)len;
}
Expand Down

0 comments on commit dea7e8e

Please sign in to comment.