Skip to content

fix: stop readString at embedded NUL bytes#33

Open
rinchen wants to merge 1 commit into
meshcore-dev:masterfrom
rinchen:fix/readstring-null-termination
Open

fix: stop readString at embedded NUL bytes#33
rinchen wants to merge 1 commit into
meshcore-dev:masterfrom
rinchen:fix/readstring-null-termination

Conversation

@rinchen

@rinchen rinchen commented Jul 19, 2026

Copy link
Copy Markdown

Summary

  • BufferReader.readString() now truncates at the first embedded NUL when present, instead of decoding the entire remainder of the frame.
  • Frames without a NUL continue to decode the full remainder.

Context

Colorado-Mesh/mesh-client currently carries this as a pnpm patch against @liamcottle/meshcore.js@1.13.0. Companion DeviceInfo and similar frames can append typed fields after a formerly remainder-string field; without NUL truncation, readString() returns garbage including those trailing bytes.

Test plan

  • Decode a frame whose remainder string contains a trailing NUL + extra bytes and confirm only the prefix is returned
  • Decode a frame with no NUL and confirm full remainder decoding is unchanged

Some companion frames append trailing fields after a string that used to be
frame-remainder. Decoding past an embedded NUL produces garbage for callers
that still use readString(). Truncate at the first NUL when present.

Carried as a pnpm patch in Colorado-Mesh/mesh-client.
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.

1 participant