haproxy-spoe-go icon indicating copy to clipboard operation
haproxy-spoe-go copied to clipboard

Wrong encoding of bool value

Open daa opened this issue 1 year ago • 2 comments

Encoder doesn't set boolean data type in the buffer when the value being encoded is false: https://github.com/negasus/haproxy-spoe-go/blob/9a8c9fb7e70ae4fc3db768cdaaf84a1ff3210e84/typeddata/typeddata.go#L51-L57

False value should be 0x01, not 0x10 as it's set currently.

daa avatar May 19 '23 02:05 daa

According with section 3.1 of the documentation https://www.haproxy.org/download/1.9/doc/SPOE.txt, bool type has format: Type (4 bit) and Flag (4 bit).

Maybe I should check it out if I misunderstood?

negasus avatar May 22 '23 07:05 negasus

Quoted code transforms the true value to 0x11 which is correct: flags (higher 4 bits) are 0001 and type (lower 4 bits) is 0001 but the false value is transformed to 0x10 which is wrong: flags are 0001 and type is 0000 but should be vice versa.

daa avatar May 22 '23 10:05 daa