Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions agent/fw_drupal8.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,19 @@ NR_PHP_WRAPPER_END
#endif // OAPI

static bool nr_is_invalid_key_val_arr(nr_php_string_hash_key_t* key,
zval* val) {
zval* val,
const char* key_ident) {
if (NULL == key || 0 == ZEND_STRING_LEN(key)
|| 0 == nr_php_is_zval_valid_array(val)
|| 0 == zend_hash_num_elements(Z_ARRVAL_P(val))) {
if (NULL != key) {
nrl_warning(NRL_FRAMEWORK,
"hookImplementationsMap[%s]: invalid value for key '%s'",
key_ident, ZEND_STRING_VALUE(key));
} else {
nrl_warning(NRL_FRAMEWORK, "hookImplementationsMap[%s]: invalid key",
key_ident);
}
return true;
} else {
return false;
Expand Down Expand Up @@ -646,25 +655,28 @@ static bool nr_drupal_hook_attribute_instrument(zval* module_handler) {

ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(hook_implementation_map), hook_key,
hook_val) {
if (nr_is_invalid_key_val_arr(hook_key, hook_val)) {
nrl_warning(NRL_FRAMEWORK,
"hookImplementationsMap[hook]: invalid key or value");
if (nr_is_invalid_key_val_arr(hook_key, hook_val, "hook")) {
return false;
}

ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(hook_val), class_key, class_val) {
if (nr_is_invalid_key_val_arr(class_key, class_val)) {
nrl_warning(NRL_FRAMEWORK,
"hookImplementationsMap[class]: invalid key or value");
if (nr_is_invalid_key_val_arr(class_key, class_val, "class")) {
return false;
}

ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL_P(class_val), method_key,
module_val) {
if (NULL == method_key
|| 0 == nr_php_is_zval_valid_string(module_val)) {
nrl_warning(NRL_FRAMEWORK,
"hookImplementationsMap[method]: invalid key or value");
if (NULL != method_key) {
nrl_warning(
NRL_FRAMEWORK,
"hookImplementationsMap[method]: invalid value for key '%s'",
ZEND_STRING_VALUE(method_key));
} else {
nrl_warning(NRL_FRAMEWORK,
"hookImplementationsMap[method]: invalid key");
}
return false;
}

Expand Down