AMReX-Codes / Amrvis

Amrvis is a visualization package specifically designed to read and display output and profiling data from codes built on the AMReX framework.
https://amrex-codes.github.io/amrex/docs_html/Visualization.html
16 stars 16 forks source link

GCC 10.3: Wformat-overflow #17

Open ax3l opened 2 years ago

ax3l commented 2 years ago

Spotted buffer overflows in sprintf with GCC 10.3.

X-ref: ignores https://github.com/AMReX-Codes/amrex/issues/2750 for now (can be a separate PR)

etpalmer63 commented 2 years ago

Some quick grepping leads to

Dataset.cpp:  char maxInfoV[Amrvis::LINELENGTH],  minInfoV[Amrvis::LINELENGTH];

Which leads to:

./amrex/Src/Extern/amrdata/AMReX_AmrvisConstants.H:const int LINELENGTH = 160;

I guess we cannot just change LINELENGTH because it affects how AMRDATA behaves. (see amrex/Extern/amrdata/AMReX_AmrData.cpp. I will ask wiser people.

ax3l commented 2 years ago

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++? :)

WeiqunZhang commented 2 years ago

Yes, there are quite some C strings and sprintf's that should be replaced with C++ strings.

ax3l commented 2 years ago

@WeiqunZhang can you please take a look at https://github.com/AMReX-Codes/amrex/pull/2660 ? :) That one I do not immediately get, the other things I fixed now in Amrvis.