BUG/MINOR: stats: fix segfault caused by uninitialized value in "show schema json"
Since b3d5708 ("MINOR: stats: remove implicit static trash_chunk usage") a segfault can occur when issuing "show schema json" on the stats socket. Indeed, now the dumping functions don't rely on trash_chunk anymore, but instead they rely on the appctx->chunk buffer. However, unlike other stats dumping commands, the "show schema json" only have an io handler, and no parse function. With other command, the parse function is responsible for pre-setting some data, including applet ctx reservation. Thus due to "show schema json" lacking parsing function, the applet ctx is used uninitialized, which is a bug obviously. To fix the issue we simply add a parse function for "show schema json", although all it does for now is calling applet_reserve_svcctx() for the current applet ctx. This issue was reported by @dsuch in GH #2825. It must be backported up to 3.0.
This commit is contained in:
parent
dfc403f5c6
commit
ac1f413590
10
src/stats.c
10
src/stats.c
@ -988,6 +988,14 @@ static int cli_parse_show_stat(char **args, char *payload, struct appctx *appctx
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cli_parse_show_schema_json(char **args, char *payload, struct appctx *appctx, void *private)
|
||||
{
|
||||
struct show_stat_ctx *ctx = applet_reserve_svcctx(appctx, sizeof(*ctx));
|
||||
|
||||
/* ctx is allocated, nothing else to do */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cli_io_handler_dump_info(struct appctx *appctx)
|
||||
{
|
||||
struct show_stat_ctx *ctx = appctx->svcctx;
|
||||
@ -1315,7 +1323,7 @@ static struct cli_kw_list cli_kws = {{ },{
|
||||
{ { "clear", "counters", NULL }, "clear counters [all] : clear max statistics counters (or all counters)", cli_parse_clear_counters, NULL, NULL },
|
||||
{ { "show", "info", NULL }, "show info [desc|json|typed|float]* : report information about the running process", cli_parse_show_info, cli_io_handler_dump_info, NULL },
|
||||
{ { "show", "stat", NULL }, "show stat [desc|json|no-maint|typed|up]*: report counters for each proxy and server", cli_parse_show_stat, cli_io_handler_dump_stat, cli_io_handler_release_stat },
|
||||
{ { "show", "schema", "json", NULL }, "show schema json : report schema used for stats", NULL, cli_io_handler_dump_json_schema, NULL },
|
||||
{ { "show", "schema", "json", NULL }, "show schema json : report schema used for stats", cli_parse_show_schema_json, cli_io_handler_dump_json_schema, NULL },
|
||||
{ { "dump", "stats-file", NULL }, "dump stats-file : dump stats for restore", cli_parse_dump_stat_file, cli_io_handler_dump_stat_file, cli_io_handler_release_dump_stat_file },
|
||||
{{},}
|
||||
}};
|
||||
|
Loading…
x
Reference in New Issue
Block a user