fix: Replace strcat with strlcat for robustness#1685
Merged
xezon merged 7 commits intoTheSuperHackers:mainfrom Oct 15, 2025
Merged
fix: Replace strcat with strlcat for robustness#1685xezon merged 7 commits intoTheSuperHackers:mainfrom
xezon merged 7 commits intoTheSuperHackers:mainfrom
Conversation
11 tasks
xezon
reviewed
Oct 12, 2025
There was a problem hiding this comment.
Note that strlcpy, strlcat will have a tiny computational overhead over strcpy, strcat, for the benefit of stability. When touching hot code, such as AsciiString, UnicodeString, be extra mindful about it.
Generally, prefer using ARRAY_SIZE(buffer) instead of sizeof(buffer) or BUFFER_SIZE_VALUE. Because ARRAY_SIZE(buffer) works for both char* and wchar_t* and adapts without touching when the actual buffer changes.
Examples:
wchar_t buffer[123];
wcslcpy(buffer, src, sizeof(buffer)); // <---- wrong! sizeof(buffer) is too large and allows buffer overflow: better ARRAY_SIZE(buffer)char buffer[MAX_PATH];
strlcpy(buffer, src, MAX_PATH); // <---- correct, but needs to be kept in sync with declaration: better ARRAY_SIZE(buffer)073cb7f to
02fdae5
Compare
Author
|
I don't understand why it doesn't compile VC6. Works fine on my PC. |
|
Try change |
415e947 to
0537c28
Compare
added 7 commits
October 15, 2025 20:12
No understanding why this occurs, but this fixes it.
Author
|
Rebased and replicated in generals |
0537c28 to
14e6641
Compare
fbraz3
pushed a commit
to fbraz3/GeneralsX
that referenced
this pull request
Nov 10, 2025
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.
This change replaces strcat with strlcat for robustness
TODO