suboption 2 (remote id) of option 82 (agent information option) is incorrectly parsed if it ends with 00
During blq v4 testing I came across small corner case. If suboption 2 (remote id), of option 82 (agent information option) ends with 00 (or it's multiple) - Kea will trim zeros.
Example:
- client sends option 82 - 52 08 02 06 01 02 0c 03 0a 22
- 52 - code
- 08 - length of entire option 82
- 02 - code of suboption
- 06 - length of suboption
- 01 02 0c 03 0a 22 - content of suboption
Kea parse, and send back correct option (52 08 02 06 01 02 0c 03 0a 22) , but if:
- client sends option 82 - 52 08 02 06 01 02 0c 03 0a 00 Kea will send back:
- 52 - code
- 08 - length of entire option 82
- 02 - code of suboption
- 05 - length of suboption << reduced length
- 01 02 0c 03 0a - content of suboption << smaller value than client send
This will go further, Kea will trim not only last octet but all 00 from the back. Please compare packets 5 and 6 from shows described scenario. 1 - 28 packets, Discovery<>Offer Request<>Reply exchanges use 00 more at the end. 29-60 packets show similar scenario but with suboption 12 (relay id) which is correct capture.pcap
Saved leases during this test leases.csv Logs kea.log
This is not affecting BLQ work, this option is trimmed also in BLQ. The same error on saving leases and retrieving it leads to correctly returned leases. That is if we assume that client will accept different content of option 82 and not discard an offer.
If suboption 12 (relay id) is used there are NO similar problems.