summaryrefslogtreecommitdiff
path: root/src/sp_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp_utils.c')
-rw-r--r--src/sp_utils.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c
index 034aaf4..6161859 100644
--- a/src/sp_utils.c
+++ b/src/sp_utils.c
@@ -253,15 +253,11 @@ const zend_string* sp_zval_to_zend_string(const zval* zv) {
253 } 253 }
254} 254}
255 255
256bool sp_match_value(const zend_string* value, const zend_string* to_match, 256bool sp_match_value(const zend_string* value, const zend_string* to_match, const sp_regexp* rx) {
257 const sp_pcre* rx) {
258 if (to_match) { 257 if (to_match) {
259 return (sp_zend_string_equals(to_match, value)); 258 return (sp_zend_string_equals(to_match, value));
260 } else if (rx) { 259 } else if (rx) {
261 char* tmp = zend_string_to_char(value); 260 return sp_is_regexp_matching_zstr(rx, value);
262 bool ret = sp_is_regexp_matching(rx, tmp);
263 efree(tmp);
264 return ret;
265 } 261 }
266 return true; 262 return true;
267} 263}
@@ -338,8 +334,7 @@ void sp_log_disable_ret(const char* restrict path,
338 efree(char_repr); 334 efree(char_repr);
339} 335}
340 336
341bool sp_match_array_key(const zval* zv, const zend_string* to_match, 337bool sp_match_array_key(const zval* zv, const zend_string* to_match, const sp_regexp* rx) {
342 const sp_pcre* rx) {
343 zend_string* key; 338 zend_string* key;
344 zend_ulong idx; 339 zend_ulong idx;
345 340
@@ -363,8 +358,7 @@ bool sp_match_array_key(const zval* zv, const zend_string* to_match,
363 return false; 358 return false;
364} 359}
365 360
366bool sp_match_array_value(const zval* arr, const zend_string* to_match, 361bool sp_match_array_value(const zval* arr, const zend_string* to_match, const sp_regexp* rx) {
367 const sp_pcre* rx) {
368 zval* value; 362 zval* value;
369 363
370 ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(arr), value) { 364 ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(arr), value) {
@@ -380,8 +374,7 @@ bool sp_match_array_value(const zval* arr, const zend_string* to_match,
380 return false; 374 return false;
381} 375}
382 376
383bool /* success */ _hook_function(const char* original_name, HashTable* hook_table, 377bool /* success */ _hook_function(const char* original_name, HashTable* hook_table, zif_handler new_function) {
384 zif_handler new_function) {
385 zend_function* func; 378 zend_function* func;
386 if ((func = zend_hash_str_find_ptr(CG(function_table), VAR_AND_LEN(original_name)))) { 379 if ((func = zend_hash_str_find_ptr(CG(function_table), VAR_AND_LEN(original_name)))) {
387 if (func->type != ZEND_INTERNAL_FUNCTION) { 380 if (func->type != ZEND_INTERNAL_FUNCTION) {
@@ -393,8 +386,7 @@ bool /* success */ _hook_function(const char* original_name, HashTable* hook_tab
393 if (zend_hash_str_add_new_ptr((hook_table), VAR_AND_LEN(original_name), 386 if (zend_hash_str_add_new_ptr((hook_table), VAR_AND_LEN(original_name),
394 func->internal_function.handler) == NULL) { 387 func->internal_function.handler) == NULL) {
395 // LCOV_EXCL_START 388 // LCOV_EXCL_START
396 sp_log_err("function_pointer_saving", 389 sp_log_err("function_pointer_saving", "Could not save function pointer for %s", original_name);
397 "Could not save function pointer for %s", original_name);
398 return false; 390 return false;
399 // LCOV_EXCL_STOP 391 // LCOV_EXCL_STOP
400 } 392 }
@@ -404,8 +396,7 @@ bool /* success */ _hook_function(const char* original_name, HashTable* hook_tab
404 return false; 396 return false;
405} 397}
406 398
407bool hook_function(const char* original_name, HashTable* hook_table, 399bool hook_function(const char* original_name, HashTable* hook_table, zif_handler new_function) {
408 zif_handler new_function) {
409 bool ret = _hook_function(original_name, hook_table, new_function); 400 bool ret = _hook_function(original_name, hook_table, new_function);
410 401
411#if PHP_VERSION_ID < 80000 402#if PHP_VERSION_ID < 80000
@@ -433,8 +424,7 @@ bool hook_function(const char* original_name, HashTable* hook_table,
433 return ret; 424 return ret;
434} 425}
435 426
436int hook_regexp(const sp_pcre* regexp, HashTable* hook_table, 427int hook_regexp(const sp_pcre* regexp, HashTable* hook_table, zif_handler new_function) {
437 zif_handler new_function) {
438 zend_string* key; 428 zend_string* key;
439 429
440 ZEND_HASH_FOREACH_STR_KEY(CG(function_table), key) 430 ZEND_HASH_FOREACH_STR_KEY(CG(function_table), key)