From 385cf2e1fcc4540f78d59956acbc239eedab16b5 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 20 Nov 2018 22:40:46 -0500 Subject: [PATCH] avoid array overflows and silence compiler warnings --- src/USER-REAXC/reaxc_io_tools.cpp | 2 +- src/USER-REAXC/reaxc_tool_box.cpp | 2 +- src/USER-REAXC/reaxc_traj.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/USER-REAXC/reaxc_io_tools.cpp b/src/USER-REAXC/reaxc_io_tools.cpp index b63fee2309..c3cb9825ff 100644 --- a/src/USER-REAXC/reaxc_io_tools.cpp +++ b/src/USER-REAXC/reaxc_io_tools.cpp @@ -38,7 +38,7 @@ int Init_Output_Files( reax_system *system, control_params *control, output_controls *out_control, mpi_datatypes *mpi_data, char *msg ) { - char temp[MAX_STR]; + char temp[MAX_STR+8]; int ret; if( out_control->write_steps > 0 ){ diff --git a/src/USER-REAXC/reaxc_tool_box.cpp b/src/USER-REAXC/reaxc_tool_box.cpp index 4fc6796efe..1678d0a53c 100644 --- a/src/USER-REAXC/reaxc_tool_box.cpp +++ b/src/USER-REAXC/reaxc_tool_box.cpp @@ -43,7 +43,7 @@ int Tokenize( char* s, char*** tok ) char *word; int count=0; - strncpy( test, s, MAX_LINE ); + strncpy( test, s, MAX_LINE-1); for( word = strtok(test, sep); word; word = strtok(NULL, sep) ) { strncpy( (*tok)[count], word, MAX_LINE ); diff --git a/src/USER-REAXC/reaxc_traj.cpp b/src/USER-REAXC/reaxc_traj.cpp index c1f3e8ae8f..8a8de2707c 100644 --- a/src/USER-REAXC/reaxc_traj.cpp +++ b/src/USER-REAXC/reaxc_traj.cpp @@ -315,7 +315,7 @@ int Init_Traj( reax_system *system, control_params *control, output_controls *out_control, mpi_datatypes *mpi_data, char *msg ) { - char fname[MAX_STR]; + char fname[MAX_STR+8]; int atom_line_len[ NR_OPT_ATOM ] = { 0, 0, 0, 0, ATOM_BASIC_LEN, ATOM_wV_LEN, ATOM_wF_LEN, ATOM_FULL_LEN };