TCP padding must stay within 1..256, including the 0x80 delimiter

dnsdist drops queries with more.

The minimal padding is 1..64 bytes, so adding 0 to 3 random blocks
of 64 bytes keeps it in range.

Fixes #3368
This commit is contained in:
Frank Denis 2026-10-15 23:04:10 +02:00
parent 121cf7871e
commit 7019609060

View file

@ -188,7 +188,7 @@ func (proxy *Proxy) Encrypt(
if _, err := crypto_rand.Read(xpad[:]); err != nil {
return nil, nil, nil, queryEpoch, err
}
minQuestionSize += int(xpad[0])
minQuestionSize += int(xpad[0]&3) * 64
}
paddedLength := Min(MaxDNSUDPPacketSize, (Max(minQuestionSize, QueryOverhead)+1+63) & ^63)
if serverInfo.knownBugs.fragmentsBlocked && proto == "udp" {