-
Notifications
You must be signed in to change notification settings - Fork 528
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
[C++] stringop-overflow warning in generateConstPropertyMethods output #832
Comments
Can you post the snippet of the schema for the field? |
It is the ftp://ftp.cmegroup.com/SBEFix/Production/Templates/templates_FixBinary.xml
|
For constant values I can kind of see a point here. However this issue would exist regardless for required values if the user filled all values of the array with chars and did not put in a null termination. Adding the null terminator like you suggest might be the safest way to go. |
While building SBE-generated C++ code for
<group>
fields, I see the following compiler warning for code generated from Group->Field elements with achar
primitive type:warning: 'strlen' argument missing terminating nul [-Wstringop-overflow=]
The generated code block looks like this:
Inspecting the situation, I see that:
mDEntryTypeLength()
mDEntryType()
truly a pointer to a singlechar
, not a NULL-terminated string.So in that regard, this is not a SBE codegen bug. But, unfortunately any C++ programmer can pass that
const char*
to a myriad of functions that expect the input to be NULL terminated. This could lead to inadvertent out-of-bounds / buffer-overrun bugs.Adding a NULL to the static array in that function would mitigate this class of bugs at small expense of static storage. So something like this at this line:
While I'm here, I'd also like to thank you for all your fantastic contributions and thought leadership to both software engineering at-large and particularly in the trading community. 🤗
The text was updated successfully, but these errors were encountered: