Fix incorrect name encoding/decoding in DNS records#5064
Conversation
1a92f78 to
2351661
Compare
2351661 to
ae384c3
Compare
ae384c3 to
5a82ddf
Compare
There was a problem hiding this comment.
Is the comment still accurate ?
40a46bd to
970ec5b
Compare
Motivation: - The decoded name should always end with a dot (.), but we currently strip it, which is incorrect. - (O) 0 -> "." - (X) 0 -> "" - (O) 5 netty 2 io 0 -> "netty.io." - (X) 5 netty 2 io 0 -> "netty.io" - The encoded name should end with a null-label, which is a label whose length is 0, but we currently append an extra NUL, causing FORMERR(1) on a strict DNS server: - (O) . -> 0 - (X) . -> 0 0 - (O) netty.io. -> 5 netty 2 io 0 - (X) netty.io. -> 5 netty 2 io 0 0 Modifications: - Make sure to append '.' when decoding a name. - Improve index checks so that the decoder can raise CorruptFrameException instead of IIOBE - Do not encode extra NUL - Add more tests Result: Robustness and correctness
970ec5b to
ab30af7
Compare
|
@rkapsi can you have a look as well ? |
|
For the record, @normanmaurer and I had different interpretation on the encoding of a name. He thinks |
|
The spec is a bit confusing ... I previously thought the same as @normanmaurer .... but it looks like we were wrong. dig netty.io: the important part: this is followed by the type |
|
Cherry-picked into 4.1 as 4b38b72 |
|
@trustin Thanks! |
|
@Scottmitch @normanmaurer Thanks for a quick confirmation and cherry-pick! Will release CR6 today because I need it badly. |
Motivation:
strip it, which is incorrect.
length is 0, but we currently append an extra NUL, causing FORMERR(1)
on a strict DNS server:
Modifications:
CorruptFrameException instead of IIOBE
Result:
Robustness and correctness