Skip to content

CMFSUPPORT-3863. COVERITY TEST. DO NOT MERGE - #58

Closed
scthunderbolt wants to merge 2 commits into
developfrom
feature/test-workflow1
Closed

CMFSUPPORT-3863. COVERITY TEST. DO NOT MERGE#58
scthunderbolt wants to merge 2 commits into
developfrom
feature/test-workflow1

Conversation

@scthunderbolt

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings April 2, 2026 18:08
@scthunderbolt
scthunderbolt requested review from a team as code owners April 2, 2026 18:08
if ((file = fopen(fpath, "w")))
{
fprintf(file,"%s",str);
fprintf(file,"%s%s",str);

Check warning

Code scanning / CodeQL

Too few arguments to formatting function Medium

Format for fprintf expects 2 arguments but given 1

Copilot Autofix

AI 3 days ago

To fix this class of issue, ensure every format specifier in fprintf has a corresponding argument, or simplify the format to match the provided arguments.

Best fix here (without changing behavior): in source/AdvSecurityDml/cosa_adv_security_internal.c, inside advsec_write_to_file, replace:

  • fprintf(file,"%s%s",str);
    with:
  • fprintf(file, "%s", str);

This preserves the apparent intent (write str to file) while removing undefined behavior. No new imports, methods, or definitions are needed.

Suggested changeset 1
source/AdvSecurityDml/cosa_adv_security_internal.c

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/source/AdvSecurityDml/cosa_adv_security_internal.c b/source/AdvSecurityDml/cosa_adv_security_internal.c
--- a/source/AdvSecurityDml/cosa_adv_security_internal.c
+++ b/source/AdvSecurityDml/cosa_adv_security_internal.c
@@ -316,7 +316,7 @@
 
     if ((file = fopen(fpath, "w")))
     {
-        fprintf(file,"%s%s",str);
+        fprintf(file, "%s", str);
         fclose(file);
         return 1;
     }
EOF
@@ -316,7 +316,7 @@

if ((file = fopen(fpath, "w")))
{
fprintf(file,"%s%s",str);
fprintf(file, "%s", str);
fclose(file);
return 1;
}
Copilot is powered by AI and may make mistakes. Always verify output.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR modifies the internal helper used to write strings to a file in the Advanced Security DML component.

Changes:

  • Updates the fprintf format string used by advsec_write_to_file().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +297 to 299
fprintf(file,"%s%s",str);
fclose(file);
return 1;

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

fprintf(file, "%s%s", str); is undefined behavior because the format string expects two %s arguments but only one is provided. This can crash or leak stack data. Use a single %s (or add the intended second string argument, e.g., a newline/terminator) and consider checking fprintf’s return value if write failures matter here.

Suggested change
fprintf(file,"%s%s",str);
fclose(file);
return 1;
int written = fprintf(file, "%s", str);
fclose(file);
return (written >= 0) ? 1 : 0;

Copilot uses AI. Check for mistakes.
if ((file = fopen(fpath, "w")))
{
fprintf(file,"%s",str);
fprintf(file,"%s%s",str);

Check warning

Code scanning / Coverity

Missing argument to printf format specifier Warning

PRINTF_ARGS: No argument for format specifier "%s".
Comment thread source/AdvSecurityDml/cosa_adv_security_internal.c Dismissed
@scthunderbolt
scthunderbolt deleted the feature/test-workflow1 branch April 2, 2026 18:31
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 2, 2026
@scthunderbolt scthunderbolt added the invalid This doesn't seem right label Apr 3, 2026
@scthunderbolt
scthunderbolt restored the feature/test-workflow1 branch July 31, 2026 15:16
@scthunderbolt scthunderbolt reopened this Jul 31, 2026
@scthunderbolt
scthunderbolt deleted the feature/test-workflow1 branch July 31, 2026 16:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants