Skip to content

fix: Validate raw data size - #85

Merged
elementbound merged 5 commits into
foxssake:mainfrom
IZ-sandwich:main
Sep 9, 2026
Merged

elementbound merged 5 commits into
foxssake:mainfrom
IZ-sandwich:main

Conversation

@IZ-sandwich

Copy link
Copy Markdown
Contributor

This PR addresses an issue with TrimsockReader where it can be put into a state it can never leave. If queuedRawCommand (on js side, but similar issue exists with raw_command in gd) is set with a non-integer size or size > maxSize every subsequent read() returns undefined regardless of what other input is sent.

The way the reader gets into a bad state is a bad size in raw command sets queuedRawCommand but it is cleared only in the happy path so gets stuck.

I found this issue with my noray server hanging, seemingly being up but not responding to register commands. I suspect it was a crawler making a generic HTTP request containing \r\n and bricking it. Additionally, I found that the sockets were not being detached on close or errors, so fixed that.

I focused on fixing the js side since that's the used dependency of noray, but made similar changes on the godot side, exposing the ingest error as a signal.

Will need to send out a followup pr to upgrade noray to use the newer version of trimsock.

@elementbound elementbound left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge kudos for the fix! 🎉 Added some thoughts and a few questions.

Comment thread trimsock.gd/addons/trimsock.gd/line_reader.gd Outdated
Comment thread trimsock.gd/addons/trimsock.gd/reader.gd
Comment thread trimsock.gd/addons/trimsock.gd/reader.gd Outdated
Comment thread trimsock.gd/addons/trimsock.gd/reader.gd
Comment thread trimsock.gd/tests/reactor.test.gd Outdated
Comment thread trimsock.js/packages/trimsock-js/spec/reader.spec.ts Outdated
Comment thread trimsock.js/packages/trimsock-js/spec/reader.spec.ts Outdated
Comment thread trimsock.js/packages/trimsock-js/spec/reader.spec.ts Outdated
Comment thread trimsock.js/packages/trimsock-node/lib/node.socket.reactor.ts
Comment thread trimsock.js/packages/trimsock-node/lib/node.socket.reactor.ts
Comment thread trimsock.gd/addons/trimsock.gd/result.gd
@elementbound elementbound changed the title fix: Adding validation for raw data size parsing fix: Validate raw data size Sep 9, 2026
@elementbound
elementbound merged commit e4f9e99 into foxssake:main Sep 9, 2026
13 checks passed
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