From: Christopher Faulet Date: Mon, 25 Jan 2021 14:16:41 +0000 (+0100) Subject: BUG/MINOR: stats: Init the metric variable when frontend stats are filled X-Git-Tag: v2.4-dev7~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8596bfbafdd161f51a25bc2f6c37b87b2cddd089;p=thirdparty%2Fhaproxy.git BUG/MINOR: stats: Init the metric variable when frontend stats are filled In stats_fill_fe_stats(), some fields are conditionnal (ST_F_HRSP_* for instance). But unlike unimplemented fields, for those fields, the variable is used to fill the array, but it is not initialized. This bug as no impact, because these fields are not used. But it is better to fix it now to avoid future bugs. To fix it, the metric is now defined and initialized into the for loop. The bug was introduced by the commit 0ef54397 ("MEDIUM: stats: allow to select one field in `stats_fill_fe_stats`"). No backport is needed except if the above commit is backported. It fixes the issue #1063. --- diff --git a/src/stats.c b/src/stats.c index e1b350a440..1b8fad3409 100644 --- a/src/stats.c +++ b/src/stats.c @@ -1632,12 +1632,13 @@ int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len, enum stat_field *selected_field) { enum stat_field current_field = (selected_field != NULL ? *selected_field : 0); - struct field metric; if (len < ST_F_TOTAL_FIELDS) return 0; for (; current_field < ST_F_TOTAL_FIELDS; current_field++) { + struct field metric = { 0 }; + switch (current_field) { case ST_F_PXNAME: metric = mkf_str(FO_KEY|FN_NAME|FS_SERVICE, px->id);