Skip to content
Open
Show file tree
Hide file tree
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
Prev Previous commit
Next Next commit
simplify return value - always a string
This approach adds some level of protection (compiler type checking) from
misusing the API.
  • Loading branch information
lavarou authored and anmol-ap committed Mar 13, 2025
commit c1981dbeb76ce53ec2fd74b2af1b3fc357eb6644
12 changes: 6 additions & 6 deletions agent/csec_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "php_compat.h"
#include "php_newrelic.h"

int nr_php_csec_get_metadata(const nr_php_csec_metadata_key_t key, void** p) {
int nr_php_csec_get_metadata(const nr_php_csec_metadata_key_t key, char** p) {
const char* value = NULL;

if (NULL == p) {
Expand All @@ -27,12 +27,12 @@ int nr_php_csec_get_metadata(const nr_php_csec_metadata_key_t key, void** p) {

switch (key) {
case NR_PHP_CSEC_METADATA_HIGH_SECURITY:
*p = nr_zalloc(sizeof(int));
if (NULL == *p) {
return -3;
if (NRPRG(app)->info.high_security) {
value = "true";
} else {
value = "false";
}
*((int*)*p) = NRPRG(app)->info.high_security;
return 0;
break;
case NR_PHP_CSEC_METADATA_ENTITY_NAME:
value = nr_app_get_entity_name(NRPRG(app));
break;
Expand Down
7 changes: 4 additions & 3 deletions agent/csec_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ typedef enum {
/*
* Purpose : Copy requested app meta data into allocated *value.
* The caller is responsible for freeing the memory
* allocated.
* allocated. The value is a string representation of
* the requested metadata.
*
* Params : Pointer to a nr_php_csec_metadata_t structure
*
Expand All @@ -32,7 +33,7 @@ typedef enum {
* -4 for invalid metadata key
* -5 for inability to retrieve metadata value
*/
extern int nr_php_csec_get_metadata(const nr_php_csec_metadata_key_t k, void** value);
typedef int (*nr_php_csec_get_metadata_t)(const nr_php_csec_metadata_key_t k, void** value);
extern int nr_php_csec_get_metadata(const nr_php_csec_metadata_key_t k, char** value);
typedef int (*nr_php_csec_get_metadata_t)(const nr_php_csec_metadata_key_t k, char** value);
#define NR_PHP_CSEC_GET_METADATA "nr_php_csec_get_metadata"
#endif