From: Willy Tarreau Date: Wed, 23 Oct 2019 04:21:05 +0000 (+0200) Subject: BUG/MINOR: stick-table: fix an incorrect 32 to 64 bit key conversion X-Git-Tag: v2.1-dev3~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=28c63c15f572a1afeabfdada6a0a4f4d023d05fc;p=thirdparty%2Fhaproxy.git BUG/MINOR: stick-table: fix an incorrect 32 to 64 bit key conversion As reported in issue #331, the code used to cast a 32-bit to a 64-bit stick-table key is wrong. It only copies the 32 lower bits in place on little endian machines or overwrites the 32 higher ones on big endian machines. It ought to simply remove the wrong cast dereference. This bug was introduced when changing stick table keys to samples in 1.6-dev4 by commit bc8c404449 ("MAJOR: stick-tables: use sample types in place of dedicated types") so it the fix must be backported as far as 1.6. --- diff --git a/src/stick_table.c b/src/stick_table.c index 86ea3ceea5..c9f3e0636d 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -927,7 +927,7 @@ struct stktable_key *smp_to_stkey(struct sample *smp, struct stktable *t) /* The stick table require a 32bit unsigned int, "sint" is a * signed 64 it, so we can convert it inplace. */ - *(unsigned int *)&smp->data.u.sint = (unsigned int)smp->data.u.sint; + smp->data.u.sint = (unsigned int)smp->data.u.sint; static_table_key.key = &smp->data.u.sint; static_table_key.key_len = 4; break;