Skip to content

Commit 3360378

Browse files
committed
Address review
1 parent 35ed40b commit 3360378

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

sapi/fpm/fpm/fpm_php.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ int fpm_php_limit_extensions(char *path) /* {{{ */
252252
}
253253
/* }}} */
254254

255-
bool fpm_php_is_key_in_table(zend_string *table, char *key, size_t key_len) /* {{{ */
255+
bool fpm_php_is_key_in_table(zend_string *table, const char *key, size_t key_len) /* {{{ */
256256
{
257257
zval *data;
258258
zend_string *str;
@@ -266,7 +266,9 @@ bool fpm_php_is_key_in_table(zend_string *table, char *key, size_t key_len) /* {
266266

267267
/* find the table and ensure it's an array */
268268
data = zend_hash_find(&EG(symbol_table), table);
269-
ZEND_ASSERT(data && Z_TYPE_P(data) == IS_ARRAY);
269+
if (!data || Z_TYPE_P(data) != IS_ARRAY) {
270+
return NULL;
271+
}
270272

271273
ZEND_HASH_FOREACH_STR_KEY(Z_ARRVAL_P(data), str) {
272274
if (str && zend_string_equals_cstr(str, key, key_len)) {

sapi/fpm/fpm/fpm_php.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#ifndef FPM_PHP_H
44
#define FPM_PHP_H 1
55

6-
#include <stdbool.h>
76
#include <TSRM.h>
87

98
#include "php.h"
@@ -42,6 +41,6 @@ void fpm_php_soft_quit(void);
4241
int fpm_php_init_main(void);
4342
int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode);
4443
int fpm_php_limit_extensions(char *path);
45-
bool fpm_php_is_key_in_table(zend_string *table, char *key, size_t key_len);
44+
bool fpm_php_is_key_in_table(zend_string *table, const char *key, size_t key_len);
4645

4746
#endif

sapi/fpm/fpm/fpm_status.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ int fpm_status_handle_request(void) /* {{{ */
143143
int full, encode, has_start_time;
144144
char *short_syntax, *short_post;
145145
char *full_pre, *full_syntax, *full_post, *full_separator;
146-
zend_string *_GET_str;
147146

148147
if (!SG(request_info).request_uri) {
149148
return 0;
@@ -168,11 +167,13 @@ int fpm_status_handle_request(void) /* {{{ */
168167

169168
/* STATUS */
170169
if (fpm_status_uri && !strcmp(fpm_status_uri, SG(request_info).request_uri)) {
170+
zend_string *_GET_str;
171+
171172
fpm_request_executing();
172173

173174
/* full status ? */
174175
_GET_str = ZSTR_INIT_LITERAL("_GET", 0);
175-
full = fpm_php_is_key_in_table(_GET_str, "full", strlen("full"));
176+
full = fpm_php_is_key_in_table(_GET_str, ZEND_STRL("full"));
176177
short_syntax = short_post = NULL;
177178
full_separator = full_pre = full_syntax = full_post = NULL;
178179
encode = 0;
@@ -215,7 +216,7 @@ int fpm_status_handle_request(void) /* {{{ */
215216
}
216217

217218
/* HTML */
218-
if (fpm_php_is_key_in_table(_GET_str, "html", strlen("html"))) {
219+
if (fpm_php_is_key_in_table(_GET_str, ZEND_STRL("html"))) {
219220
sapi_add_header_ex(ZEND_STRL("Content-Type: text/html"), 1, 1);
220221
time_format = "%d/%b/%Y:%H:%M:%S %z";
221222
encode = 1;
@@ -284,7 +285,7 @@ int fpm_status_handle_request(void) /* {{{ */
284285
}
285286

286287
/* XML */
287-
} else if (fpm_php_is_key_in_table(_GET_str, "xml", strlen("xml"))) {
288+
} else if (fpm_php_is_key_in_table(_GET_str, ZEND_STRL("xml"))) {
288289
sapi_add_header_ex(ZEND_STRL("Content-Type: text/xml"), 1, 1);
289290
time_format = "%s";
290291
encode = 1;
@@ -332,7 +333,7 @@ int fpm_status_handle_request(void) /* {{{ */
332333
}
333334

334335
/* JSON */
335-
} else if (fpm_php_is_key_in_table(_GET_str, "json", strlen("json"))) {
336+
} else if (fpm_php_is_key_in_table(_GET_str, ZEND_STRL("json"))) {
336337
sapi_add_header_ex(ZEND_STRL("Content-Type: application/json"), 1, 1);
337338
time_format = "%s";
338339

@@ -379,7 +380,7 @@ int fpm_status_handle_request(void) /* {{{ */
379380
}
380381

381382
/* OpenMetrics */
382-
} else if (fpm_php_is_key_in_table(_GET_str, "openmetrics", strlen("openmetrics"))) {
383+
} else if (fpm_php_is_key_in_table(_GET_str, ZEND_STRL("openmetrics"))) {
383384
sapi_add_header_ex(ZEND_STRL("Content-Type: application/openmetrics-text; version=1.0.0; charset=utf-8"), 1, 1);
384385
time_format = "%s";
385386

0 commit comments

Comments
 (0)