Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Fix hardening checks in std::string operator[] #122414

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

winner245
Copy link
Contributor

The current valid-element-access hardening checks in the operator[] for basic_string are improperly implemented, which do not trap accesses one past the end of the string. This PR corrects the issue and adds corresponding assertion tests to validate the checks.

@winner245 winner245 force-pushed the fix-string-hardening branch from 2b43926 to 0d909b9 Compare January 10, 2025 04:19
@frederick-vs-ja
Copy link
Contributor

No... I believe the existing checks are correct, because the standard specifies that s[s.size()] is well-defined and can even refer to a writable object! Although a program is only permitted to write CharT() to it. (Unfortunately, I have no idea how to check this.)

See

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.

2 participants