Repository navigation
Conversation
Reveares
force-pushed
the
fix/string-frm-count
branch
from
November 19, 2026 23:10
a8b2f56 to
2df108e
Compare
Owner
|
Hi, @Reveares and thanks for the find! Forwarding to |
Contributor
Author
|
Yes, keeping the specialized version also works. Your version was correct, but CI failed. To verify you can build with ASan, rename a ZEN to a long name and pass it with #include <cstdint>
#include <cstdio>
#include <string>
#include "string_frm.h"
int main(int argc, char**) {
string_frm warn("RaysCasted: ", argc); // GCC: -Warray-bounds on PR 45e69d6
for(size_t n=0; n<200; ++n) {
std::string a(n, 'a');
string_frm s(a.c_str(), 'b', a.c_str());
if(std::string_view(s) != a+'b'+a)
std::printf("FAIL at %zu\n", n);
return 1;
}
std::puts(warn.c_str());
return 0;
}
On master this will output |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
string_frmformats twice: into its 64-byte buffer to measure the text, then into a heap buffer of that size. Theconst char*overload stopped counting once the 64-byte buffer was full, so a C string argument after that point was measured short and the second pass wrote past the heap buffer.This happens for the sky texture. It formats
SKYDAY_<stem>_LAYER<n>_A0.TGAwith the world's name, so any world whose file name stem is 41 bytes or longer overruns the heap. ASan reports a heap-buffer-overflow inimplWrite.The
const char*overload now forwards to thestring_viewone.