Skip to content

parser: bound the stream parser on an incomplete message - #324

Merged
emiago merged 1 commit into
emiago:mainfrom
Mliviu79:pr/parser-bound
Aug 7, 2026
Merged

parser: bound the stream parser on an incomplete message#324
emiago merged 1 commit into
emiago:mainfrom
Mliviu79:pr/parser-bound

Conversation

@Mliviu79

@Mliviu79 Mliviu79 commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #323

The size limit was only checked once a message parsed in full, so a peer that never finishes one was never stopped.

The size limit was only checked once a message parsed in full, so a peer that
never finishes one was never stopped. On the partial-parse path ParseNext now
sums totalRead and the buffer length and returns ErrMessageTooLarge when that
exceeds MaxMessageLength, discarding the buffered bytes: an unfinished message
leaves no boundary to resync on.

Neither pool is bounded alone. Complete header lines drain into the message and
keep the buffer near empty while the message grows; a line that never terminates
does the reverse. Only their sum bounds the peer.

TCP closes the connection on ErrMessageTooLarge rather than reading on.

Refs emiago#323
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sip: stream parser does not bound an incomplete message

2 participants