Skip to content

Fix UB issue which can be caused by not init proto_len before reading it#961

Merged
normanmaurer merged 1 commit intomainfrom
proto_len
Mar 23, 2026
Merged

Fix UB issue which can be caused by not init proto_len before reading it#961
normanmaurer merged 1 commit intomainfrom
proto_len

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

Motivation:

We failed to initialize proto_len and so could end up to undefined behavior.

Modifications:

  • proto_len is now initialized to 0 — eliminating the undefined behaviour from reading it uninitialized.
  • The CHOOSE_MY_LAST_PROTOCOL branch is now guarded with proto != NULL — if the peer sent no protocols (inlen == 0) the inner loop never runs and proto stays NULL,
    so we correctly fall through to SSL_TLSEXT_ERR_NOACK instead of doing arithmetic on a null/garbage pointer.

Result:

Fix UB

Motivation:

We failed to initialize proto_len and so could end up to undefined behavior.

Modifications:

- proto_len is now initialized to 0 — eliminating the undefined behaviour from reading it uninitialized.
- The CHOOSE_MY_LAST_PROTOCOL branch is now guarded with proto != NULL — if the peer sent no protocols (inlen == 0) the inner loop never runs and proto stays NULL,
   so we correctly fall through to SSL_TLSEXT_ERR_NOACK instead of doing arithmetic on a null/garbage pointer.

Result:

Fix UB
@normanmaurer normanmaurer added this to the 2.0.76.Final milestone Mar 23, 2026
@normanmaurer normanmaurer merged commit 8bd4739 into main Mar 23, 2026
10 checks passed
@normanmaurer normanmaurer deleted the proto_len branch March 23, 2026 10:34
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