Skip to content

CMFSUPPORT-3890 : COVERITY TEST. DO NOT MERGE - #11

Closed
snampo768 wants to merge 1 commit into
developfrom
feature/test-workflow
Closed

CMFSUPPORT-3890 : COVERITY TEST. DO NOT MERGE#11
snampo768 wants to merge 1 commit into
developfrom
feature/test-workflow

Conversation

@snampo768

Copy link
Copy Markdown

DO NOT MERGE

@snampo768
snampo768 requested a review from a team as a code owner February 25, 2026 10:03
Copilot AI review requested due to automatic review settings February 25, 2026 10:03
Comment thread source/jst_post.c
char* cursor = content_data;
char* eof = content_data + content_len;

printf("Test coverity flow %s");

Check warning

Code scanning / CodeQL

Too few arguments to formatting function Medium

Format for printf expects 1 arguments but given 0

Copilot Autofix

AI 6 months ago

In general, to fix “too few arguments to formatting function” issues, either (a) remove or adjust the format specifiers so they match the actual number and types of arguments passed, or (b) add the missing arguments of the correct types to the call. The goal is for each % specifier in the format string to have a corresponding argument.

For this specific call in source/jst_post.c at line 701:

printf("Test coverity flow %s");

the simplest and safest fix without changing existing functionality is to remove the unused %s placeholder, because there is no obvious string we should be printing there and the message appears to just be a static debug string. Changing it to:

printf("Test coverity flow\n");

or

printf("Test coverity flow");

eliminates the format-argument mismatch while preserving the intended debug output. No new imports or helper methods are needed, and the behavior remains a simple console message. If you prefer to keep the %s for some reason, you would instead need to add a corresponding string argument, such as printf("Test coverity flow %s", "");, but that is unnecessarily confusing compared to removing the specifier.

The change is localized to the parse_mpfd function in source/jst_post.c, around line 701, and requires only editing that single printf line.

Suggested changeset 1
source/jst_post.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/jst_post.c b/source/jst_post.c
--- a/source/jst_post.c
+++ b/source/jst_post.c
@@ -698,7 +698,7 @@
 {
   char* cursor = content_data;
   char* eof = content_data + content_len;
-  printf("Test coverity flow %s");
+  printf("Test coverity flow\n");
   while(cursor < eof)
   {
     while(cursor < eof - boundary_len)
EOF
@@ -698,7 +698,7 @@
{
char* cursor = content_data;
char* eof = content_data + content_len;
printf("Test coverity flow %s");
printf("Test coverity flow\n");
while(cursor < eof)
{
while(cursor < eof - boundary_len)
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 appears to introduce intentional issues to exercise Coverity/static-analysis reporting and adjust compiler flags to avoid build breaks during that test.

Changes:

  • Added a debug printf call in multipart form-data parsing.
  • Modified build flags to enable -Werror while exempting -Werror=format.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
source/jst_post.c Adds a printf in parse_mpfd() (multipart parsing path).
source/Makefile.am Adjusts warning/error flags, including disabling -Werror for format warnings.
Comments suppressed due to low confidence (1)

source/Makefile.am:25

  • Adding -Wno-error=format (and setting AM_CPPFLAGS to it) weakens compile-time format-string checking repo-wide, which can hide real bugs and potential format-string vulnerabilities. Prefer fixing the underlying format issues (e.g., the new printf) and keeping format warnings as errors rather than globally disabling them.
AM_CFLAGS += -Werror -Wno-error=format
AM_LDFLAGS = -lccsp_common
AM_CPPFLAGS = -Wno-error=format

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

Comment thread source/jst_post.c
char* cursor = content_data;
char* eof = content_data + content_len;

printf("Test coverity flow %s");

Copilot AI Feb 25, 2026

Copy link

Choose a reason for hiding this comment

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

printf("Test coverity flow %s"); uses a %s format specifier without providing an argument, which is undefined behavior and can crash or leak memory. Also, writing to stdout from request parsing can corrupt CGI/HTTP responses; remove this debug print or replace it with the project logging facility with a correct format string and arguments.

Suggested change
printf("Test coverity flow %s");
CosaPhpExtLog("Test coverity flow\n");

Copilot uses AI. Check for mistakes.
Comment thread source/jst_post.c
char* cursor = content_data;
char* eof = content_data + content_len;

printf("Test coverity flow %s");

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.

Coverity Issue - Printf arg count mismatch

the format string requires additional arguments

Medium Impact, CWE-685
PW.TOO_FEW_PRINTF_ARGS

Comment thread source/jst_post.c
char* cursor = content_data;
char* eof = content_data + content_len;

printf("Test coverity flow %s");

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.

Coverity Issue - Missing argument to printf format specifier

No argument for format specifier "%s".

Medium Impact, CWE-685
PRINTF_ARGS

@snampo768

Copy link
Copy Markdown
Author

Close test PR

@snampo768 snampo768 closed this Feb 25, 2026
@snampo768
snampo768 deleted the feature/test-workflow branch February 25, 2026 11:27
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants