-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Use StrcpyFunction in cpp/bad-strncpy-size #9998
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
Use StrcpyFunction in cpp/bad-strncpy-size #9998
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great.
I would include a short change note, as the query now finds more results.
wchar_t buf2[20]; | ||
const wchar_t *str = L"01234567890123456789"; | ||
|
||
wcsxfrm_l(buf1, str, sizeof(buf1), nullptr); // BAD (but not a StrncpyFlippedArgs bug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(but not a StrncpyFlippedArgs bug)
I'm not sure what you're saying here, the query appears to have flagged this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good point... test9()
is a copy of test2()
pretty much, including the comments, and has the same behaviour. Namely, that line is flagged because (I'm guessing) it falls under the "Fixed sized case", which is not exactly a case of "flipped" args. At least, that's how I interpreted the original comment.
Added wcsxfrm_l, which is not currently caught by the query, meaning that in this case a successful test implies missing functionality.
As a result, the query gets access to more types of strncpy-like functions, as demonstrated by test.cpp, which now "fails" (i.e. works) for the new test cases instroduced in the previous commit.
Add output lines for the newly implemented test case, test.cpp/test9().
265e3d8
to
05f4f98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
This PR:
wcsxfrm_l
) to StrncpyFlippedArgs's test.cpp.