GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — use an unsigned accumulator in base64_encode by metsw24-max · Pull Request #2477 · yhirose/cpp-httplib

Conversation

@metsw24-max

@metsw24-max metsw24-max commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

base64_encode folds each input byte into a signed int and shifts it left by eight every round; once four bytes are in, the top bit is set and the next shift left-shifts a negative int, which is undefined behaviour (ubsan reports a left shift of a negative value, and the same shift recurs in the trailing six-bit fixup). the helper runs on the server's websocket accept-key path over the sha1 digest and in the basic-auth header builder, so it is reachable from request handling. making the accumulator a uint32_t removes the ub and keeps the output byte-for-byte identical, since every emitted six-bit group is masked with 0x3f and is independent of the accumulator's signedness. the added test pins the rfc 4648 vectors plus a high-byte input that keeps the top bit set across rounds.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@metsw24-max
use an unsigned accumulator in base64_encode
2af81bf
@yhirose

yhirose commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Looks like there are quite a few errors...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@metsw24-max
Forward-declare detail::base64_encode for split builds
cc74cb0
@metsw24-max

metsw24-max commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Those were all the same failure: the new test calls detail::base64_encode, but in the split build split.py strips inline and moves the definition into httplib.cc, so it isn't declared in the public header. I've forward-declared it in the test the same way getaddrinfo_with_timeout already is, so it resolves in both the header-only and split builds. Confirmed both compile and the test passes locally.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@yhirose
yhirose merged commit a7b886b into yhirose:master Jul 2, 2026
27 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@yhirose

yhirose commented Jul 2, 2026

Copy link
Copy Markdown
Owner

@metsw24-max thanks for your contribution!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@metsw24-max @yhirose
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.