]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stick-table: properly convert binary samples to keys
authorWilly Tarreau <w@1wt.eu>
Tue, 9 Aug 2016 10:08:41 +0000 (12:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 9 Aug 2016 12:30:57 +0000 (14:30 +0200)
The binary sample to stick-table key conversion is wrong. It doesn't
check that the binary sample is writable before padding it. After a
quick audit, it doesn't look like any existing sample fetch function
can trigger this bug. The correct fix consists in calling smp_make_rw()
prior to padding the sample.

This fix should be backported to 1.6.

src/stick_table.c

index 13816bbed28acb07012fe9a53fcf33dd2f04b123..b0aabd4092e4d736d6c24a1f78c76b38fc05b586 100644 (file)
@@ -505,6 +505,9 @@ struct stktable_key *smp_to_stkey(struct sample *smp, struct stktable *t)
        case SMP_T_BIN:
                if (smp->data.u.str.len < t->key_size) {
                        /* This type needs padding with 0. */
+                       if (!smp_make_rw(smp))
+                               return NULL;
+
                        if (smp->data.u.str.size < t->key_size)
                                if (!smp_dup(smp))
                                        return NULL;