diff options
| author | cgzones | 2026-02-22 21:10:10 +0100 |
|---|---|---|
| committer | GitHub | 2026-02-22 21:10:10 +0100 |
| commit | 50fb9d8a8f040729c3472998aea0bdd14b1b7805 (patch) | |
| tree | 4b360b03ba69c5c5e7caeea14cb304ba8e3eec87 /src/sp_utils.c | |
| parent | 9e94280c0b6356be37b8f9a0a4d2303146863a5b (diff) | |
Define PATH_MAX and update its usage
Diffstat (limited to 'src/sp_utils.c')
| -rw-r--r-- | src/sp_utils.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c index 41eb638..8b4eb35 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -4,6 +4,10 @@ | |||
| 4 | #define MIN(a,b) (((a)<(b))?(a):(b)) | 4 | #define MIN(a,b) (((a)<(b))?(a):(b)) |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | #ifndef PATH_MAX | ||
| 8 | # define PATH_MAX 4096 | ||
| 9 | #endif | ||
| 10 | |||
| 7 | static char const* const default_ipaddr = "0.0.0.0"; | 11 | static char const* const default_ipaddr = "0.0.0.0"; |
| 8 | const char* get_ipaddr() { | 12 | const char* get_ipaddr() { |
| 9 | const char* client_ip = getenv("REMOTE_ADDR"); | 13 | const char* client_ip = getenv("REMOTE_ADDR"); |
| @@ -112,7 +116,7 @@ int sp_log_request(zend_string const* const restrict folder, zend_string const* | |||
| 112 | FILE* file; | 116 | FILE* file; |
| 113 | char const* const current_filename = zend_get_executed_filename(TSRMLS_C); | 117 | char const* const current_filename = zend_get_executed_filename(TSRMLS_C); |
| 114 | const int current_line = zend_get_executed_lineno(TSRMLS_C); | 118 | const int current_line = zend_get_executed_lineno(TSRMLS_C); |
| 115 | char filename[PATH_MAX] = {0}; | 119 | char filename[PATH_MAX]; |
| 116 | static const struct { | 120 | static const struct { |
| 117 | char const* const str; | 121 | char const* const str; |
| 118 | const int key; | 122 | const int key; |
| @@ -152,7 +156,7 @@ int sp_log_request(zend_string const* const restrict folder, zend_string const* | |||
| 152 | EG(current_execute_data) = orig_execute_data; | 156 | EG(current_execute_data) = orig_execute_data; |
| 153 | PHP_SHA256Final(digest, &context); | 157 | PHP_SHA256Final(digest, &context); |
| 154 | make_digest_ex(strhash, digest, SHA256_SIZE); | 158 | make_digest_ex(strhash, digest, SHA256_SIZE); |
| 155 | snprintf(filename, PATH_MAX - 1, "%s/sp_dump.%s", ZSTR_VAL(folder), strhash); | 159 | snprintf(filename, PATH_MAX, "%s/sp_dump.%s", ZSTR_VAL(folder), strhash); |
| 156 | 160 | ||
| 157 | if (NULL == (file = fopen(filename, "w+"))) { | 161 | if (NULL == (file = fopen(filename, "w+"))) { |
| 158 | sp_log_warn("request_logging", "Unable to open %s: %s", filename, | 162 | sp_log_warn("request_logging", "Unable to open %s: %s", filename, |
