Skip to content

[FIXED] Panic in DecodeHeadersMsg on status tokens shorter than 3 characters#2101

Open
nikitha-m wants to merge 1 commit into
nats-io:mainfrom
nikitha-m:fix/panic-short-status-headers
Open

[FIXED] Panic in DecodeHeadersMsg on status tokens shorter than 3 characters#2101
nikitha-m wants to merge 1 commit into
nats-io:mainfrom
nikitha-m:fix/panic-short-status-headers

Conversation

@nikitha-m

Copy link
Copy Markdown

Problem: DecodeHeadersMsg panics with "slice bounds out of range" when the inline status token (e.g. NATS/1.0 5) is shorter than 3 characters. The guard len(status) != statusLen was meant to detect a trailing description but also matched short tokens, then attempted status[3:] on a 0-2 byte string.

Fix: Change the condition to len(status) < statusLen and return ErrBadHeaderMsg for malformed status tokens. Use len(status) > statusLen for the description split.

Resolves #2100

Signed-off-by: Nikitha Mohithe mohitenikki2002@gmail.com

…racters

Signed-off-by: Nikitha Mohithe <nikithamohite@Nikithas-MacBook-Air.local>
Signed-off-by: Nikitha Mohithe <nikithamohithe@gmail.com>
Signed-off-by: Nikitha Mohithe <mohitenikki2002@gmail.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.

bug: DecodeHeadersMsg slice out-of-range panic on short status token

1 participant