Repository navigation
Conversation
A tag with fewer than 2 elements (e.g. NIP-70's bare ["-"] protected- event marker) has no tag[1] at all. The len(tag) < 2 check that was meant to guard this short-circuited the rest of that compound OR condition correctly, but the branch it fell into then unconditionally evaluated tag[1] as a call argument to IndexLongerTag -- Go evaluates call arguments before the call, so this panicked with an out-of-range index before IndexLongerTag's own body (which does handle a short/empty value safely) ever ran. This isn't hypothetical: IndexLongerTag, once configured, is wired for every event a relay stores, not just ones it authors itself -- so any client publishing any event containing a bare single-element tag would crash the whole process. Fixed by checking len(tag) < 2 on its own, before ever touching tag[1], rather than folded into the compound condition that (correctly) still short-circuits on it but doesn't stop the later unconditional call. go build/go vet/gofmt clean.
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.
Summary
["-"]protected-event marker) has notag[1]. Thelen(tag) < 2check correctly short-circuits the rest of its compound OR condition, but the branch it falls into then unconditionally evaluatestag[1]as a call argument toIndexLongerTag— Go evaluates call arguments before the call, so this panics with an out-of-range index beforeIndexLongerTag's own body (which does handle a short/empty value safely) ever runs.IndexLongerTagis configured, it's wired for every event a relay stores, not just ones it authors — so any client publishing any event with a bare single-element tag crashes the whole process.len(tag) < 2on its own, before ever touchingtag[1], rather than folded into the compound condition that still (correctly) short-circuits on it but doesn't stop the later unconditional call.Test plan
IndexLongerTag, an event containing a bare single-element tag) before applying the fix, confirmed it no longer panics after.go build,go vet,gofmt -lall clean.