Skip to content

Comments

fix infinte loop in parser.parse()#8

Merged
zont merged 1 commit intozont:masterfrom
ruinedme:fix-large-searches
Apr 14, 2025
Merged

fix infinte loop in parser.parse()#8
zont merged 1 commit intozont:masterfrom
ruinedme:fix-large-searches

Conversation

@ruinedme
Copy link

Occasionally, when performing queries with large responses, the parser function sometimes gets stuck in an infinite loop. It appears the socket does not write only complete chunks, but will occasionally write a full chunk + plus a couple of bytes into the next chunk. usually something to the effect of [0x30, 0x84,0x00,0x00,0x00] as you can see this is the start of a sequence using a variable length byte encoding, but is missing the 6th byte. Because of this the parser will just keep recursing with this partial sequence message until it hits the stack call limit.

If we do a check to make sure the berReader has a length of 0 we just return since we know for sure there is not enough data in the buffer to proceed.

Example (pre-fix)
image

(post-fix)
image

@zont zont merged commit 3732a2a into zont:master Apr 14, 2025
1 check passed
@ruinedme ruinedme mentioned this pull request Apr 23, 2025
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.

2 participants