Le 12/01/2019 à 23:23, PiBa-NL a écrit :
Hi List,
I've configured haproxy with htx and when i try to filter the stats webpage.
Sending this request: "GET /?;csv;scope=b1" to '2.0-dev0-762475e
2019/01/10' it will crash with the trace below.
1.9.0 and 1.9.1 are also affected.
Can someone take a look? Thanks in advance.
A regtest is attached that reproduces the behavior, and which i think
could be included into the haproxy repository.
Pieter,
Here is the patch that should fix this issue. This was "just" an
oversight when the stats applet has been adapted to support the HTX.
If it's ok for you, I'll also merge your regtest.
Thanks
--
Christopher Faulet
>From d09c87cf3d261b42f02671b3ddf2cbc36b7e1916 Mon Sep 17 00:00:00 2001
From: Christopher Faulet <[email protected]>
Date: Mon, 14 Jan 2019 11:07:34 +0100
Subject: [PATCH] BUG/MEDIUM: stats: Get the rigth scope pointer depending on
HTX is used or not
For HTX streams, the scope pointer is relative to the TXN uri. But for streams
using the legacy HTTP representation, the scope pointer is relative to the
beginning of output data in the channel's buffer. So we must be carefull to use
the right one depending on the HTX is used or not.
Thanks to Pieter (PiBa-NL) to report this bug.
This patch must be backported to 1.9.
---
src/stats.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/stats.c b/src/stats.c
index ebd95d3f0..ee375af6f 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -1912,8 +1912,12 @@ static void stats_dump_html_px_hdr(struct stream_interface *si, struct proxy *px
/* scope_txt = search pattern + search query, appctx->ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */
scope_txt[0] = 0;
if (appctx->ctx.stats.scope_len) {
+ char *scope_ptr = (IS_HTX_STRM(si_strm(si))
+ ? si_strm(si)->txn->uri + appctx->ctx.stats.scope_str
+ : co_head(si_oc(si)) + appctx->ctx.stats.scope_str);
+
strcpy(scope_txt, STAT_SCOPE_PATTERN);
- memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+ memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), scope_ptr, appctx->ctx.stats.scope_len);
scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
}
@@ -2075,9 +2079,14 @@ int stats_dump_proxy_to_buffer(struct stream_interface *si, struct htx *htx,
/* if the user has requested a limited output and the proxy
* name does not match, skip it.
*/
- if (appctx->ctx.stats.scope_len &&
- strnistr(px->id, strlen(px->id), co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len) == NULL)
- return 1;
+ if (appctx->ctx.stats.scope_len) {
+ char *scope_ptr = (IS_HTX_STRM(si_strm(si))
+ ? si_strm(si)->txn->uri + appctx->ctx.stats.scope_str
+ : co_head(si_oc(si)) + appctx->ctx.stats.scope_str);
+
+ if (strnistr(px->id, strlen(px->id), scope_ptr, appctx->ctx.stats.scope_len) == NULL)
+ return 1;
+ }
if ((appctx->ctx.stats.flags & STAT_BOUND) &&
(appctx->ctx.stats.iid != -1) &&
@@ -2347,6 +2356,9 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u
struct appctx *appctx = __objt_appctx(si->end);
unsigned int up = (now.tv_sec - start_date.tv_sec);
char scope_txt[STAT_SCOPE_TXT_MAXLEN + sizeof STAT_SCOPE_PATTERN];
+ char *scope_ptr = (IS_HTX_STRM(si_strm(si))
+ ? si_strm(si)->txn->uri + appctx->ctx.stats.scope_str
+ : co_head(si_oc(si)) + appctx->ctx.stats.scope_str);
/* WARNING! this has to fit the first packet too.
* We are around 3.5 kB, add adding entries will
@@ -2405,7 +2417,7 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u
);
/* scope_txt = search query, appctx->ctx.stats.scope_len is always <= STAT_SCOPE_TXT_MAXLEN */
- memcpy(scope_txt, co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+ memcpy(scope_txt, scope_ptr, appctx->ctx.stats.scope_len);
scope_txt[appctx->ctx.stats.scope_len] = '\0';
chunk_appendf(&trash,
@@ -2417,7 +2429,7 @@ static void stats_dump_html_info(struct stream_interface *si, struct uri_auth *u
scope_txt[0] = 0;
if (appctx->ctx.stats.scope_len) {
strcpy(scope_txt, STAT_SCOPE_PATTERN);
- memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+ memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), scope_ptr, appctx->ctx.stats.scope_len);
scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
}
@@ -3136,7 +3148,7 @@ static int stats_send_htx_redirect(struct stream_interface *si, struct htx *htx)
scope_txt[0] = 0;
if (appctx->ctx.stats.scope_len) {
strcpy(scope_txt, STAT_SCOPE_PATTERN);
- memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), co_head(si_oc(si)) + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
+ memcpy(scope_txt + strlen(STAT_SCOPE_PATTERN), s->txn->uri + appctx->ctx.stats.scope_str, appctx->ctx.stats.scope_len);
scope_txt[strlen(STAT_SCOPE_PATTERN) + appctx->ctx.stats.scope_len] = 0;
}
--
2.20.1