Repository navigation
dnsext-do53: 途中で切れたメッセージはメッセージではない - #297
Open
kazu-yamamoto wants to merge 2 commits into
Open
kazu-yamamoto wants to merge 2 commits into
kazu-yamamoto wants to merge 2 commits into
Conversation
kazu-yamamoto
force-pushed
the
fix-short-vc-read
branch
from
October 10, 2026 01:25
10f169c to
3732407
Compare
kazu-yamamoto
force-pushed
the
fix-short-vc-read
branch
from
October 24, 2026 04:09
3732407 to
88e55d5
Compare
recvVC says of itself that it "returns exactly-necessary-length data.
If necessary-length data is not received, an exception is thrown." It
throws where nothing at all arrives. Where some of the message arrives
and the rest does not, it hands over what it has:
refuses a message which stopped short [x]
expected: True
but got: False
The other five say what it already does and should go on doing: a
message which arrived whole, one which arrived in pieces, one which
never started, a circuit which said nothing at all, and one longer than
the limit.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
recvVC reads the two-octet length and then that many octets, and takes
whatever comes back so long as it is not empty. A read gives back what
has arrived: a peer which sent the length and then went away leaves part
of the message behind, and that part was handed on as if it were the
whole of it.
Whoever decodes it then fails with
DecodeError "incomplete input: BufferOverrun"
which says nothing about where the message came from or what was wrong
with it, and on a connection which is read in a loop says it again for
every message after this one, the reader having lost where it was.
So the length is checked against what arrived. Nothing at all keeps the
message it had, which covers a length prefix that did not arrive either:
decodeVCLength calls a prefix it could not read zero octets long.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
kazu-yamamoto
force-pushed
the
fix-short-vc-read
branch
from
November 18, 2026 02:17
88e55d5 to
fa526d8
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
途中までしか届かなかったメッセージを、そのまま 1 つのメッセージとして受け取っていました。#195 に向けた一歩です。
どこがどう間違っていたか
dnsext-do53/DNS/Do53/IO.hsのrecvVCwith。2 オクテットの長さ接頭辞を読み、その数だけ読んで、空でない限りそのまま返します。recvNは届いた分を返します。長さを送ってから去った相手はメッセージの断片を残し、その断片が全体であるかのように返っていました。DNS.decodeに掛けてDecodeError "incomplete input: BufferOverrun"で落ちます。どこから来た何が悪いのかを言えず、ループで読む接続では、読み位置を見失ってそれ以降のすべてのメッセージで同じことを言い続けます。bowline DecodeError loop #195 が報告している毎秒 2 万行はこれです。decodeVCLengthは読めなかった接頭辞を 0 オクテットと呼ぶためです。どう直したか
読めた長さが長さ接頭辞と一致するかを見ます。
wholeは、空なら従来どおりのエラー、長さが足りなければ「何オクテットのはずが何オクテット届いたか」を言うエラー、一致すれば受け取り、です。どの層・どのパッケージ
dnsext-do53のrecvVCwith1 か所。TCP・DoT・DoH など、仮想回線からメッセージを読むすべての経路が通ります。スタブ、DoX、clove でも使われる関数なので、振る舞いの変更は「不完全なものを渡さない」ことに限っています。どう確かめたか
dnsext-do53にRecvVCSpecを追加。6 例のうち 1 例が修正前は赤です。残りの 5 例は、これまでの振る舞いを固定するものです(丸ごと届いた、分割して届いた、始まらなかった、何も言わずに切れた、上限より長い)。
cabal test all9 スイートすべて 0 failures。🤖 Generated with Claude Code