Skip to content

Commit a622bc4

Browse files
committed
[fix] metrics name compare with length
because ngx_str_t->data is not guarantee to terminate with '\n' Signed-off-by: Liu Lantao <[email protected]>
1 parent 492aeec commit a622bc4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/ngx_http_accounting_worker_process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ngx_http_accounting_handler(ngx_http_request_t *r)
100100
if (metrics == NULL)
101101
return NGX_ERROR;
102102

103-
if (ngx_strcmp(accounting_id->data, metrics->name.data) != 0)
103+
if (ngx_rstrncmp(accounting_id->data, metrics->name.data, accounting_id->len) != 0)
104104
return NGX_ERROR;
105105

106106
metrics->nr_statuses = ngx_pcalloc(ngxta_current_metrics->pool,

src/ngxta_period_metrics.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ngxta_period_rbtree_lookup_metrics(ngxta_period_rbtree_t *period,
9393
}
9494

9595
n = (ngxta_metrics_rbnode_t *) node;
96-
rc = ngx_strcmp(name->data, n->name.data);
96+
rc = ngx_rstrncmp(name->data, n->name.data, name->len);
9797

9898
if (rc < 0) {
9999
node = node->left;

0 commit comments

Comments
 (0)