Skip to content

Check decoded length and colon position#647

Open
Martin-Zeithaml wants to merge 3 commits into
v3.x/stagingfrom
v3.x/bugfix/extractBasicAuth
Open

Check decoded length and colon position#647
Martin-Zeithaml wants to merge 3 commits into
v3.x/stagingfrom
v3.x/bugfix/extractBasicAuth

Conversation

@Martin-Zeithaml

Copy link
Copy Markdown
Contributor
  • Check decodeBase64 returning -1 before it is used to index authString[decodedLength]
  • Changed if (colonPos) to if (colonPos != -1) for the missing colon
  • memcpy length from decodedLength-colonPos+1 to decodedLength-colonPos - this now copies exactly the password bytes plus the null terminator already written at authString[decodedLength], which fits the decodedLength - sized password buffer with no slack, even for the empty username edge case.

Signed-off-by: Martin Zeithaml <Martin.Zeithaml@broadcom.com>
@JoeNemo

JoeNemo commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

You are copying one fewer bytes in the memcpy. Is that your intention? Were we copy too many or too few bytes into password?

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants