-
Notifications
You must be signed in to change notification settings - Fork 53
Coverity SARIF Test. DO NOT MERGE #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ | |
| *bufLength = length; | ||
|
|
||
| } else { | ||
| printf("ERROR: bufLength %d is too small for %d chars\n", *bufLength, totalLength); | ||
| printf("ERROR: bufLength %d is too small for %d chars\n", totalLength); | ||
Check warningCode scanning / Coverity Printf arg count mismatch Warning
PW.TOO_FEW_PRINTF_ARGS: the format string requires additional arguments
Check warningCode scanning / Coverity Missing argument to printf format specifier Warning
PRINTF_ARGS: No argument for format specifier "%d".
|
||
| *bufLength = 0; | ||
|
Comment on lines
+47
to
48
|
||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -561,7 +561,7 @@ | |
|
|
||
| if(edid.IsValid()) { | ||
| ::memset(edid_info, 0, sizeof(*edid_info)); | ||
| memcpy(edid_info->manufacturer_id, edid.Manufacturer().c_str(), sizeof(edid_info->manufacturer_id)); | ||
| memcpy(edid_info->manufacturer_id, edid.Manufacturer().c_str(), 10*sizeof(edid_info->manufacturer_id)); | ||
Check failureCode scanning / Coverity Out-of-bounds access Error
OVERRUN: Overrunning array "edid_info->manufacturer_id" of 3 bytes by passing it to a function which accesses it at byte offset 29 using argument "30UL".
Check failureCode scanning / Coverity Destination buffer too small Error
BUFFER_SIZE: You might overrun the 3 byte destination string "edid_info->manufacturer_id" by writing the maximum 30 bytes from "string(edid.Manufacturer()).c_str()".
|
||
| edid_info->product_code = edid.ProductCode(); | ||
|
Comment on lines
+564
to
565
|
||
| edid_info->serial_number = edid.Serial(); | ||
| edid_info->manufacture_week = edid.Week(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -125,7 +125,7 @@ | ||||||||||||||||||||||||||||||||||
| *bufLength = length; | |||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||
| } else { | |||||||||||||||||||||||||||||||||||
| printf("ERROR: bufLength %d is too small for %d chars\n", *bufLength, totalLength); | |||||||||||||||||||||||||||||||||||
| printf("ERROR: bufLength %d is %s too small for %d chars\n", *bufLength, totalLength); | |||||||||||||||||||||||||||||||||||
Check warningCode scanning / CodeQL Too few arguments to formatting function Medium
Format for printf expects 3 arguments but given 2
Copilot AutofixAI 5 days ago In general, to fix “too few arguments to formatting function” errors, you must make the format string and the argument list consistent: every conversion specifier (e.g., For this specific case in printf("ERROR: bufLength %d is too small for %d chars\n", *bufLength, totalLength);No new methods, imports, or definitions are needed; we only change the format string in the existing
Suggested changeset
1
Source/displayinfo/display_info/main.c
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||||||||
| printf("ERROR: bufLength %d is %s too small for %d chars\n", *bufLength, totalLength); | |
| printf("ERROR: bufLength %" PRIu32 " is too small for %" PRIu32 " chars\n", | |
| *bufLength, totalLength); |
Check warning
Code scanning / Coverity
Invalid type in argument to printf format specifier Warning
Check warning
Code scanning / Coverity
Printf arg count mismatch Warning
Check warning
Code scanning / Coverity
Missing argument to printf format specifier Warning
Check warning
Code scanning / CodeQL
Too few arguments to formatting function Medium
Copilot Autofix
AI 5 days ago
In general, to fix “too few arguments to formatting function” issues, you either (1) adjust the format string so it matches the number and types of the actual arguments, or (2) add the missing arguments so they match the format string. Here, the error message clearly intends to mention two values: the provided buffer length and the required number of characters. We already have
totalLength(the required length), and we also have the caller-provided*bufLength. So the best fix is to pass both of these as arguments toprintf, matching the two%dplaceholders.Concretely, in
Source/deviceinfo/device_info/main.c, insidetoHexString, update line 47 from:to:
This preserves the behavior (now properly informing the caller what buffer length was provided and what was required) and removes the undefined behavior. No new headers, methods, or other definitions are needed.