mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 14:21:25 +02:00
Since commit 6879ad3 ("MEDIUM: sample: fill the struct sample with the session, proxy and stream pointers") merged in 1.6-dev2, the sample contains the pointer to the stream and sample fetch functions as well as converters use it heavily. The problem is that earlier commit 87b0966 ("REORG/MAJOR: session: rename the "session" entity to "stream"") had split the session and stream resulting in the possibility for smp->strm to be NULL before the stream was initialized. This is what happens in tcp-request connection rulesets, as discovered by Baptiste. The sample fetch functions must now check that smp->strm is valid before using it. An alternative could consist in using a dummy stream with nothing in it to avoid some checks but it would only result in deferring them to the next step anyway, and making it harder to detect that a stream is valid or the dummy one. There is still an issue with variables which requires a complete independant fix. They use strm->sess to find the session with strm possibly NULL and passed as an argument. All call places indirectly use smp->strm to build strm. So the problem is there but the API needs to be changed to remove this duplicate argument that makes it much harder to know what pointer to use. This fix must be backported to 1.6, as well as the next one fixing variables.