From: Andreas Seltenreich Date: Thu, 3 Mar 2016 18:32:25 +0000 (+0100) Subject: CLEANUP: stats: Avoid computation with uninitialized bits. X-Git-Tag: v1.7-dev2~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9727cf482cc4f761a2649fd04149f17bb3143600;p=thirdparty%2Fhaproxy.git CLEANUP: stats: Avoid computation with uninitialized bits. stats_map_lookup() sets bit SMP_F_CONST in the uninitialized member flags of a stack-allocated sample, leaving the other bits uninitialized. All code paths that can access the struct only ever check for this specific flag, so there is no risk of unintended behavior. Nevertheless fix it as it triggers warnings in static code analysis tools and might become a problem on future revisions of the code. Problem found in version 1.5. --- diff --git a/src/dumpstats.c b/src/dumpstats.c index 0ffbd5ac01..fd35fe319c 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -5858,7 +5858,7 @@ static int stats_map_lookup(struct stream_interface *si) /* execute pattern matching */ sample.data.type = SMP_T_STR; - sample.flags |= SMP_F_CONST; + sample.flags = SMP_F_CONST; sample.data.u.str.len = appctx->ctx.map.chunk.len; sample.data.u.str.str = appctx->ctx.map.chunk.str; if (appctx->ctx.map.expr->pat_head->match &&