GCC 10.3: Wformat-overflow#17
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 ? :) |
| sprintf(minInfoV, fstring, rMin); | ||
| sprintf(minInfo, "Min:%s", minInfoV); | ||
| XmString sNewMin = XmStringCreateSimple(minInfo); | ||
| std::string minInfo("Min:"); |
There was a problem hiding this comment.
I did not change this for compatibility, but we could add a space here:
| std::string minInfo("Min:"); | |
| std::string minInfo("Min: "); |
| sprintf(maxInfoV, fstring, rMax); | ||
| sprintf(maxInfo, "Max:%s", maxInfoV); | ||
| XmString sNewMax = XmStringCreateSimple(maxInfo); | ||
| std::string maxInfo("Max:"); |
There was a problem hiding this comment.
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
sprintfwith GCC 10.3.X-ref: ignores AMReX-Codes/amrex#2750 for now (can be a separate PR)