Commit 9eea02a0 authored by Jonathan Jenkins's avatar Jonathan Jenkins
Browse files

posix dirname call overwrites string, prevent it

parent 99f3f2ed
...@@ -162,7 +162,11 @@ static void codes_kernel_helper_parse_cf(char * io_kernel_path, char * ...@@ -162,7 +162,11 @@ static void codes_kernel_helper_parse_cf(char * io_kernel_path, char *
token = strtok_r(NULL, " \n", &ctx); token = strtok_r(NULL, " \n", &ctx);
if(token) { if(token) {
if (use_relpath){ if (use_relpath){
sprintf(io_kernel_path, "%s/%s", dirname(io_kernel_meta_path), token); /* posix dirname overwrites argument :(, need to
* prevent that */
char *tmp_path = strdup(io_kernel_meta_path);
sprintf(io_kernel_path, "%s/%s", dirname(tmp_path), token);
free(tmp_path);
} }
else{ else{
strcpy(io_kernel_path, token); strcpy(io_kernel_path, token);
......
...@@ -28,6 +28,7 @@ int configuration_load (const char *filepath, ...@@ -28,6 +28,7 @@ int configuration_load (const char *filepath,
char *txtdata; char *txtdata;
char *error; char *error;
int rc; int rc;
char *tmp_path;
rc = MPI_File_open(comm, (char*)filepath, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh); rc = MPI_File_open(comm, (char*)filepath, MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);
assert(rc == MPI_SUCCESS); assert(rc == MPI_SUCCESS);
...@@ -65,7 +66,10 @@ int configuration_load (const char *filepath, ...@@ -65,7 +66,10 @@ int configuration_load (const char *filepath,
fclose(f); fclose(f);
(*handle)->config_dir = strdup(dirname(filepath)); /* NOTE: posix version overwrites argument :(. */
tmp_path = strdup(filepath);
(*handle)->config_dir = strdup(dirname(tmp_path));
free(tmp_path);
return rc; return rc;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment