BUG/MINOR: sample: fix the json converter's endian-sensitivity
authorWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 07:37:37 +0000 (08:37 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 28 Feb 2020 09:58:31 +0000 (10:58 +0100)
commit2d3b5dc62346e70c44a42d4b2064fb9dd888e182
treefd962af59cc59304a6d54638d30a9138a94164c3
parentc9aeee22f1c61e08e48fb6df12c58a2b25f8b7e7
BUG/MINOR: sample: fix the json converter's endian-sensitivity

About every time there's a pointer cast in the code, there's a hidden
bug, and this one was no exception, as it passes the first octet of the
native representation of an integer as a single-character string, which
obviously only works on little endian machines. On big-endian machines,
something as simple as "str(foo),json" only returns zeroes.

This bug was introduced with the JSON converter in 1.6-dev1 by commit
317e1c4f1e ("MINOR: sample: add "json" converter"), the fix may be
backported to all stable branches.

(cherry picked from commit 5715da269d6ec1e178b04d1c7aa25982e10873d7)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/sample.c