From c9d6c2316eae830fd244b56207e4eb774eb6ca3a Mon Sep 17 00:00:00 2001 From: "Julian M. Kunkel" Date: Thu, 30 Nov 2017 12:01:19 +0100 Subject: [PATCH] Bugfix for self referencing sprintf #20 Backmerge from IOR fork. --- src/mdtest.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mdtest.c b/src/mdtest.c index 2bc66bc..95777fd 100644 --- a/src/mdtest.c +++ b/src/mdtest.c @@ -1822,7 +1822,7 @@ int main(int argc, char **argv) { MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &size); - + /* NCMPI backend uses numTaskWorld as size */ numTasksWorld = size; @@ -2161,12 +2161,12 @@ int main(int argc, char **argv) { fflush(stdout); } - strcpy(testdir, testdirpath); + int pos = sprintf(testdir, "%s", testdirpath); if ( testdir[strlen( testdir ) - 1] != '/' ) { - strcat(testdir, "/"); + pos += sprintf(& testdir[pos], "/"); } - strcat(testdir, TEST_DIR); - sprintf(testdir, "%s.%d", testdir, j); + pos += sprintf(& testdir[pos], "%s", TEST_DIR); + pos += sprintf(& testdir[pos], ".%d", j); if (verbose >= 2 && rank == 0) { printf( "V-2: main (for j loop): making testdir, \"%s\"\n", testdir );