Validate string weight byte lengths during decoding#8715
Open
dfgvaetyj3456356-hash wants to merge 1 commit into
Open
Validate string weight byte lengths during decoding#8715dfgvaetyj3456356-hash wants to merge 1 commit into
dfgvaetyj3456356-hash wants to merge 1 commit into
Conversation
Signed-off-by: dfgvaetyj3456356-hash <dfgvaetyj3456356-hash@users.noreply.github.com>
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.
This adds explicit validation for string tensor weight payloads while decoding TFJS weights.
Previously, the ArrayBuffer decode path could accept a malformed string weight whose length prefix declared more bytes than were actually present. ArrayBuffer slicing caps to the available bytes, so a truncated payload could be decoded as a shorter string instead of being rejected. The streaming path already failed on this class of malformed input; this change makes both paths reject incomplete string length prefixes or string payload bytes with a clear error.
Changes:
Validation:
I also attempted the targeted Bazel test from a no-space Windows worktree. Bazel analysis started, but the Windows TypeScript worker failed before compiling tests because the generated shell wrapper under the Bazel execroot was missing (external/npm/@bazel/concatjs/bin/tsc_wrapped.sh). A direct TypeScript check was also blocked by missing repo dev dependencies/types in this fresh clone.