Skip to content

Conversation

@Skyaero42
Copy link

@Skyaero42 Skyaero42 commented Oct 18, 2025

Replacing strcpy for strlcpy where applicable

  • No replacement when strcpy contains a magic string (verified that magic string fits into target parameter)
  • As with strlcat, ASCIIString and UnicodeString have not been touched.
  • No replacement when target parameter is a pointer instead of a char[].

TODO:

  • Replicate in Generals.

@Skyaero42 Skyaero42 added this to the Stability fixes milestone Oct 18, 2025
@Skyaero42 Skyaero42 self-assigned this Oct 18, 2025
@Skyaero42 Skyaero42 added Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing Stability Concerns stability of the runtime labels Oct 18, 2025
@Skyaero42 Skyaero42 force-pushed the skyaero/strcpy-to-strlcpy branch from 498a8e9 to db9bc33 Compare October 18, 2025 20:05
@Skyaero42 Skyaero42 force-pushed the skyaero/strcpy-to-strlcpy branch from db9bc33 to a11e0e0 Compare October 19, 2025 19:27
@Skyaero42 Skyaero42 marked this pull request as ready for review October 19, 2025 19:27
@Skyaero42 Skyaero42 changed the title fix: Replace strcat with strlcat for robustness fix: Replace strcpy with strlcpy for robustness Oct 21, 2025
@CollabCheck-StockholmUni

This comment was marked as off-topic.

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Munkees really loved their string buffers.

Before continuing this change, I think we need another change that gets rid of all the redundant and obsolete buffer copies that I have raised in this review. I don't know if I caught them all, so more reviewing is required.

*/
case REG_BINARY:
strcpy(save_name, "BIN_");
strlcpy(save_name, "BIN_", ARRAY_SIZE(save_name));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strcpy is safe here

if (pList == NULL) return;
pList->ResetContent();
strcpy(findBuf, dirBuf);
strlcpy(findBuf, dirBuf, ARRAY_SIZE(findBuf));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strcpy is safe

if (pList == NULL) return;
pList->ResetContent();
strcpy(findBuf, dirBuf);
strlcpy(findBuf, dirBuf, ARRAY_SIZE(fileBuf));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strcpy is safe

continue;
}
strcpy(fileBuf, dirBuf);
strlcpy(fileBuf, dirBuf, ARRAY_SIZE(fileBuf));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strcpy is safe

dirBuf[len] = 0;
}
strcpy(findBuf, dirBuf);
strlcpy(findBuf, dirBuf, ARRAY_SIZE(findBuf));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strcpy is safe

AsciiString filename = *it;
//strcpy(fileBuf, dirBuf);
strcpy(fileBuf, filename.str());
//strlcpy(fileBuf, dirBuf, ARRAY_SIZE(fileBuf));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can just remove this commented code.

@Skyaero42 Skyaero42 force-pushed the skyaero/strcpy-to-strlcpy branch from a11e0e0 to cd6da64 Compare October 31, 2025 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing Stability Concerns stability of the runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants