]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: stick-tables: do not fail on string keys with no allocated size
authorWilly Tarreau <w@1wt.eu>
Tue, 9 Aug 2016 09:59:12 +0000 (11:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 9 Aug 2016 12:30:57 +0000 (14:30 +0200)
commitce6955e632df7605edbd3418cbbc239e0a1106a8
treed5ec52b04ffaf59c3832ddbe8075b61705a78176
parent2e0565cc09517195ed50d5a121852b654c9d2b97
BUG/MEDIUM: stick-tables: do not fail on string keys with no allocated size

When a stick-table key is derived from a string-based sample, it checks
if it's properly zero-terminated otherwise tries to do so. But the test
doesn't work for two reasons :
  - the reported allocated size may be zero while the sample is maked as
    not CONST (eg: certain sample fetch functions like smp_fetch_base()
    do this), so smp_dup() prior to the recent changes will fail on this.

  - the string might have been converted from a binary sample, where the
    trailing zero is not appended. If the sample was writable, smp_dup()
    would not modify it either and we would fail again here. This may
    happen with req.payload or req.body_param for example.

The correct solution consists in calling smp_make_safe() to ensure the
sample is usable as a valid string.

This fix must be backported to 1.6.
src/stick_table.c