intel / mpi-benchmarks

146 stars 63 forks source link

Fix buffer overflow in snprintf #55

Closed Flamefire closed 2 months ago

Flamefire commented 3 months ago

IMB_display_times writes a string of size 106 into a buffer of size 104 and even using an offset which will make this worse by writing even further out of bounds. Increase the buffer size by a constant to avoid this.

 ../src_c/IMB_output.c: In Funktion »IMB_display_times«:
 ../src_c/IMB_output.c:346:152: Fehler: » int-overflow; The productio...«-Direktive schreibt 106 Bytes in eine Region der Größe 104 [-Werror=format-overflow=]
   346 |                 sprintf(aux_string + offset, " int-overflow; The production rank*size caused int overflow for given sample; use flag \"-data_type double\"");
       |                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
 ../src_c/IMB_output.c:346:17: Anmerkung: »sprintf« hat 107 Byte in ein Ziel der Größe 104 ausgegeben
   346 |                 sprintf(aux_string + offset, " int-overflow; The production rank*size caused int overflow for given sample; use flag \"-data_type double\"");
       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
JuliaRS commented 2 months ago

fixed in master