Skip to content

Handle short inputs in gzip and wasm detection helpers#1748

Open
modernzju wants to merge 1 commit into
scrtlabs:masterfrom
modernzju:master
Open

Handle short inputs in gzip and wasm detection helpers#1748
modernzju wants to merge 1 commit into
scrtlabs:masterfrom
modernzju:master

Conversation

@modernzju

Copy link
Copy Markdown

Summary

This PR hardens the IsGzip and IsWasm helper functions so they return false for empty or truncated inputs instead of panicking when slicing the input buffer.

It also updates the unit tests to cover nil/short input cases and uses a minimal wasm header fixture for these magic-byte checks.

Why

Both helpers previously sliced the input before checking its length:

  • input[:3] for gzip detection
  • input[:4] for wasm detection

That can panic if callers pass empty data or a partially read file. Returning false is safer and matches the helpers' boolean detection behavior.

Testing

go test -v -tags "secretcli" ./x/compute/client/utils

Signed-off-by: modernzju <modernzju@outlook.com>
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