CMFSUPPORT-3765: COVERITY TEST. DO NOT MERGE#86
Conversation
There was a problem hiding this comment.
Pull request overview
This PR appears to be a test change for Coverity analysis and is explicitly marked "DO NOT MERGE" in both the title and description. The change modifies a sprintf_s call to add an extra format specifier without providing a corresponding argument, introducing a critical bug.
Changes:
- Modified sprintf_s format string to add a third "%s" specifier without providing a third argument
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else | ||
| { | ||
| rc = sprintf_s(pFullName, sizeof(pFullName), "%s%s", pRootName, buffer); | ||
| rc = sprintf_s(pFullName, sizeof(pFullName), "%s%s%s", pRootName, buffer); |
There was a problem hiding this comment.
This change introduces a critical bug. The format string now contains three format specifiers ("%s%s%s") but only two arguments are provided (pRootName and buffer). This mismatch will cause undefined behavior when sprintf_s attempts to read a third argument that doesn't exist, potentially leading to crashes or memory corruption.
The original code with two format specifiers ("%s%s") correctly matched the two provided arguments. Looking at the similar pattern on line 1236, the else branch on line 1243 should concatenate pRootName and buffer without adding a trailing dot (since buffer already ends with a dot based on the condition on line 1234). The format string should remain "%s%s" with two arguments.
| rc = sprintf_s(pFullName, sizeof(pFullName), "%s%s%s", pRootName, buffer); | |
| rc = sprintf_s(pFullName, sizeof(pFullName), "%s%s", pRootName, buffer); |
| else | ||
| { | ||
| rc = sprintf_s(pFullName, sizeof(pFullName), "%s%s", pRootName, buffer); | ||
| rc = sprintf_s(pFullName, sizeof(pFullName), "%s%s%s", pRootName, buffer); |
There was a problem hiding this comment.
Coverity Issue - Missing argument to printf format specifier
No argument for format specifier "%s".
Medium Impact, CWE-685
PRINTF_ARGS
|
Close PR |
DO NOT MERGE