-
Notifications
You must be signed in to change notification settings - Fork 16
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
GCC 10.3: Wformat-overflow #17
base: main
Are you sure you want to change the base?
Conversation
Some quick grepping leads to
Which leads to:
I guess we cannot just change LINELENGTH because it affects how AMRDATA behaves. (see |
Jup, it's basically writing a string added to a prefix in a same-size string a couple of time. I would say we trash the C pointer logic and make it C++? :) |
Yes, there are quite some C strings and sprintf's that should be replaced with C++ strings. |
Spotted buffer overflows in `sprintf` with GCC 10.3
6f677d5
to
c3c74b4
Compare
Fix string buffer overflows in two files.
@WeiqunZhang can you please take a look at AMReX-Codes/amrex#2660 ? :) |
@@ -431,14 +432,16 @@ void Dataset::DatasetRender(const Box &alignedRegion, AmrPicture *apptr, | |||
XmStringFree(sNewLevel); | |||
|
|||
sprintf(minInfoV, fstring, rMin); | |||
sprintf(minInfo, "Min:%s", minInfoV); | |||
XmString sNewMin = XmStringCreateSimple(minInfo); | |||
std::string minInfo("Min:"); |
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.
I did not change this for compatibility, but we could add a space here:
std::string minInfo("Min:"); | |
std::string minInfo("Min: "); |
XtVaSetValues(wMinValue, XmNlabelString, sNewMin, NULL); | ||
XmStringFree(sNewMin); | ||
|
||
sprintf(maxInfoV, fstring, rMax); | ||
sprintf(maxInfo, "Max:%s", maxInfoV); | ||
XmString sNewMax = XmStringCreateSimple(maxInfo); | ||
std::string maxInfo("Max:"); |
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.
I did not change this for compatibility, but we could add a space here:
std::string maxInfo("Max:"); | |
std::string maxInfo("Max: "); |
Spotted buffer overflows in
sprintf
with GCC 10.3.X-ref: ignores AMReX-Codes/amrex#2750 for now (can be a separate PR)