Skip to content

Commit 7019609

Browse files
committed
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
1 parent 121cf78 commit 7019609

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎dnscrypt-proxy/crypto.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func (proxy *Proxy) Encrypt(
188188
if _, err := crypto_rand.Read(xpad[:]); err != nil {
189189
return nil, nil, nil, queryEpoch, err
190190
}
191-
minQuestionSize += int(xpad[0])
191+
minQuestionSize += int(xpad[0]&3) * 64
192192
}
193193
paddedLength := Min(MaxDNSUDPPacketSize, (Max(minQuestionSize, QueryOverhead)+1+63) & ^63)
194194
if serverInfo.knownBugs.fragmentsBlocked && proto == "udp" {

0 commit comments

Comments
 (0)