Skip to content

strings: fix data corruption in Base64Escape due to aliasing#2017

Closed
Aspen-coder wants to merge 1 commit intoabseil:masterfrom
Aspen-coder:fix/base64-aliasing-safety
Closed

strings: fix data corruption in Base64Escape due to aliasing#2017
Aspen-coder wants to merge 1 commit intoabseil:masterfrom
Aspen-coder:fix/base64-aliasing-safety

Conversation

@Aspen-coder
Copy link

@Aspen-coder Aspen-coder commented Feb 14, 2026

Description:
Addressed a data corruption bug in the pointer-based overloads of Base64Escape and WebSafeBase64Escape.
For a full description (as well as comments that led me to the solution), see: #2015

The Problem:
When the input string_view aliases the destination std::string, the internal implementation can potentially overwrite the source data before the encoding is complete, leading to corrupted output / undefined behavior.

The Fix:
Modified the implementation to route these calls through the string-returning overloads.

Testing:
Added a regression test Base64Escape.AliasingSafety in absl/strings/escaping_test.cc. Verified passing with bazel test //absl/strings:escaping_test.

@google-cla
Copy link

google-cla bot commented Feb 14, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Aspen-coder Aspen-coder force-pushed the fix/base64-aliasing-safety branch from 00d364b to c9257e8 Compare February 14, 2026 16:14
@amtajkhan58-oss
Copy link

amtajkhan58-oss commented Feb 14, 2026 via email

@derekmauro
Copy link
Member

Thanks for your interest in Abseil. A preferred fix for this issue has already been submitted: 586a3fb

@derekmauro derekmauro closed this Feb 15, 2026
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.

3 participants