[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.2a2-111-ga30a472

Service Account noreply at mpich.org
Wed Jan 14 16:42:40 CST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".

The branch, master has been updated
       via  a30a4721a2d6d8e35b0f33069689d3f0b527c745 (commit)
       via  ed39c90123dbe32a574ce4106874587369d778ce (commit)
      from  bb1c9db61ffb2e8c7a92e4d5d0d965a066480cdf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/a30a4721a2d6d8e35b0f33069689d3f0b527c745

commit a30a4721a2d6d8e35b0f33069689d3f0b527c745
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Mon Jan 12 16:23:14 2015 -0600

    use PATH_MAX instead of magic number
    
    User on OpenMPI list wanted to create a 259 character file.  shared file
    pointer name construction used the magic '256' value to construct a full
    path to the hidden shared file pointer file.  PATH_MAX already exists
    for this purpose, so use it.
    
    While there, found a few spots checking/setting PATH_MAX, so do that in
    one place
    
    Closes #2212
    
    Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>

diff --git a/src/mpi/romio/adio/common/ad_fstype.c b/src/mpi/romio/adio/common/ad_fstype.c
index e2c41ea..c89b560 100644
--- a/src/mpi/romio/adio/common/ad_fstype.c
+++ b/src/mpi/romio/adio/common/ad_fstype.c
@@ -137,10 +137,6 @@ Output Parameters:
 */
 #ifdef ROMIO_NEEDS_ADIOPARENTDIR
 
-#ifndef PATH_MAX
-#define PATH_MAX 65535
-#endif
-
 /* In a strict ANSI environment, S_ISLNK may not be defined.  Fix that
    here.  We assume that S_ISLNK is *always* defined as a macro.  If
    that is not universally true, then add a test to the romio
diff --git a/src/mpi/romio/adio/common/shfp_fname.c b/src/mpi/romio/adio/common/shfp_fname.c
index f1e5eee..dfa5baf 100644
--- a/src/mpi/romio/adio/common/shfp_fname.c
+++ b/src/mpi/romio/adio/common/shfp_fname.c
@@ -21,8 +21,11 @@
    store the shared file pointer. The shared-file-pointer file is a 
    hidden file in the same directory as the real file being accessed.
    If the real file is /tmp/thakur/testfile, the shared-file-pointer
-   file will be /tmp/thakur/.testfile.shfp.xxxx, where xxxx is
-   a random number. This file is created only if the shared
+   file will be /tmp/thakur/.testfile.shfp.yyy.xxxx, where yyy
+   is rank 0's process id and xxxx is a random number. If the
+   underlying file system supports shared file pointers
+   (PVFS does not, for example), the file name is always
+   constructed. This file is created only if the shared
    file pointer functions are used and is deleted when the real
    file is closed. */
 
@@ -33,14 +36,14 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank, int *error_code)
     char *slash, *ptr, tmp[128];
     int pid = 0;
 
-    fd->shared_fp_fname = (char *) ADIOI_Malloc(256);
+    fd->shared_fp_fname = (char *) ADIOI_Malloc(PATH_MAX);
 
     if (!rank) {
         srand(time(NULL));
         i = rand();
 	pid = (int)getpid();
 	
-	if (ADIOI_Strncpy(fd->shared_fp_fname, fd->filename, 256)) {
+	if (ADIOI_Strncpy(fd->shared_fp_fname, fd->filename, PATH_MAX)) {
 	    *error_code = ADIOI_Err_create_code("ADIOI_Shfp_fname",
 		    fd->filename, ENAMETOOLONG);
 	    return;
@@ -57,7 +60,7 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank, int *error_code)
 			fd->filename, ENAMETOOLONG);
 		return;
 	    }
-	    if (ADIOI_Strncpy(fd->shared_fp_fname + 1, fd->filename, 255)) {
+	    if (ADIOI_Strncpy(fd->shared_fp_fname + 1, fd->filename, PATH_MAX-1)) {
 		*error_code = ADIOI_Err_create_code("ADIOI_Shfp_fname",
 			fd->filename, ENAMETOOLONG);
 		return;
@@ -76,7 +79,7 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank, int *error_code)
 		return;
 	    }
 	    /* ok to cast: file names bounded by PATH_MAX and NAME_MAX */
-	    len = (int) (256 - (slash+2 - fd->shared_fp_fname));
+	    len = (int) (PATH_MAX - (slash+2 - fd->shared_fp_fname));
 	    if (ADIOI_Strncpy(slash + 2, ptr + 1, len)) {
 		*error_code = ADIOI_Err_create_code("ADIOI_Shfp_fname",
 			ptr + 1, ENAMETOOLONG);
@@ -86,7 +89,7 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank, int *error_code)
 	    
 	ADIOI_Snprintf(tmp, 128, ".shfp.%d.%d", pid, i);
 	/* ADIOI_Strnapp will return non-zero if truncated.  That's ok */
-	ADIOI_Strnapp(fd->shared_fp_fname, tmp, 256);
+	ADIOI_Strnapp(fd->shared_fp_fname, tmp, PATH_MAX);
 	
 	len = (int)strlen(fd->shared_fp_fname);
 	MPI_Bcast(&len, 1, MPI_INT, 0, fd->comm);
diff --git a/src/mpi/romio/adio/common/system_hints.c b/src/mpi/romio/adio/common/system_hints.c
index 5d0e24b..fd6cba5 100644
--- a/src/mpi/romio/adio/common/system_hints.c
+++ b/src/mpi/romio/adio/common/system_hints.c
@@ -28,10 +28,6 @@
 #include <io.h>
 #endif
 
-#ifndef PATH_MAX
-#define PATH_MAX 65535
-#endif
-
 /*#define SYSHINT_DEBUG 1  */
 
 #define ROMIO_HINT_DEFAULT_CFG "/etc/romio-hints"
diff --git a/src/mpi/romio/adio/include/adioi.h b/src/mpi/romio/adio/include/adioi.h
index 67dd91e..eab98e5 100644
--- a/src/mpi/romio/adio/include/adioi.h
+++ b/src/mpi/romio/adio/include/adioi.h
@@ -1034,7 +1034,13 @@ typedef struct wcThreadFuncData {
 void *ADIOI_IO_Thread_Func(void *vptr_args);
 
 
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
 
+#ifndef PATH_MAX
+#define PATH_MAX 65535
+#endif
 
 #endif
 

http://git.mpich.org/mpich.git/commitdiff/ed39c90123dbe32a574ce4106874587369d778ce

commit ed39c90123dbe32a574ce4106874587369d778ce
Author: Rob Latham <robl at mcs.anl.gov>
Date:   Mon Jan 12 15:50:32 2015 -0600

    make ADIOI_Shfp_fname report errors
    
    Right now there's only one error condition: file name too long.  This
    change checks return codes of ADIOI_Strncpy and informs caller.
    Otherwise, really long names result in buffer overruns.
    
    See #2212
    
    Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>

diff --git a/src/mpi/romio/adio/common/shfp_fname.c b/src/mpi/romio/adio/common/shfp_fname.c
index 3761cf8..f1e5eee 100644
--- a/src/mpi/romio/adio/common/shfp_fname.c
+++ b/src/mpi/romio/adio/common/shfp_fname.c
@@ -26,7 +26,7 @@
    file pointer functions are used and is deleted when the real
    file is closed. */
 
-void ADIOI_Shfp_fname(ADIO_File fd, int rank)
+void ADIOI_Shfp_fname(ADIO_File fd, int rank, int *error_code)
 {
     int i;
     int len;
@@ -40,7 +40,11 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank)
         i = rand();
 	pid = (int)getpid();
 	
-	ADIOI_Strncpy(fd->shared_fp_fname, fd->filename, 256);
+	if (ADIOI_Strncpy(fd->shared_fp_fname, fd->filename, 256)) {
+	    *error_code = ADIOI_Err_create_code("ADIOI_Shfp_fname",
+		    fd->filename, ENAMETOOLONG);
+	    return;
+	}
 	
 #ifdef ROMIO_NTFS
 	slash = strrchr(fd->filename, '\\');
@@ -48,8 +52,16 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank)
 	slash = strrchr(fd->filename, '/');
 #endif
 	if (!slash) {
-	    ADIOI_Strncpy(fd->shared_fp_fname, ".", 2);
-	    ADIOI_Strncpy(fd->shared_fp_fname + 1, fd->filename, 255);
+	    if (ADIOI_Strncpy(fd->shared_fp_fname, ".", 2)) {
+		*error_code = ADIOI_Err_create_code("ADIOI_Shfp_fname",
+			fd->filename, ENAMETOOLONG);
+		return;
+	    }
+	    if (ADIOI_Strncpy(fd->shared_fp_fname + 1, fd->filename, 255)) {
+		*error_code = ADIOI_Err_create_code("ADIOI_Shfp_fname",
+			fd->filename, ENAMETOOLONG);
+		return;
+	    }
 	}
 	else {
 	    ptr = slash;
@@ -58,13 +70,22 @@ void ADIOI_Shfp_fname(ADIO_File fd, int rank)
 #else
 	    slash = strrchr(fd->shared_fp_fname, '/');
 #endif
-	    ADIOI_Strncpy(slash + 1, ".", 2);
+	    if (ADIOI_Strncpy(slash + 1, ".", 2))  {
+		*error_code = ADIOI_Err_create_code("ADIOI_Shfp_fname",
+			fd->filename, ENAMETOOLONG);
+		return;
+	    }
 	    /* ok to cast: file names bounded by PATH_MAX and NAME_MAX */
 	    len = (int) (256 - (slash+2 - fd->shared_fp_fname));
-	    ADIOI_Strncpy(slash + 2, ptr + 1, len);
+	    if (ADIOI_Strncpy(slash + 2, ptr + 1, len)) {
+		*error_code = ADIOI_Err_create_code("ADIOI_Shfp_fname",
+			ptr + 1, ENAMETOOLONG);
+		return;
+	    }
 	}
 	    
 	ADIOI_Snprintf(tmp, 128, ".shfp.%d.%d", pid, i);
+	/* ADIOI_Strnapp will return non-zero if truncated.  That's ok */
 	ADIOI_Strnapp(fd->shared_fp_fname, tmp, 256);
 	
 	len = (int)strlen(fd->shared_fp_fname);
diff --git a/src/mpi/romio/adio/include/adioi.h b/src/mpi/romio/adio/include/adioi.h
index 02cea30..67dd91e 100644
--- a/src/mpi/romio/adio/include/adioi.h
+++ b/src/mpi/romio/adio/include/adioi.h
@@ -691,7 +691,7 @@ ADIO_Offset ADIOI_GEN_SeekIndividual(ADIO_File fd, ADIO_Offset offset,
 void ADIOI_GEN_Resize(ADIO_File fd, ADIO_Offset size, int *error_code);
 void ADIOI_GEN_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code);
 void ADIOI_GEN_Close(ADIO_File fd, int *error_code);
-void ADIOI_Shfp_fname(ADIO_File fd, int rank);
+void ADIOI_Shfp_fname(ADIO_File fd, int rank, int *error_code);
 void ADIOI_GEN_Prealloc(ADIO_File fd, ADIO_Offset size, int *error_code);
 int ADIOI_Error(ADIO_File fd, int error_code, char *string);
 int MPIR_Err_setmsg( int, int, const char *, const char *, const char *, ... );
diff --git a/src/mpi/romio/mpi-io/open.c b/src/mpi/romio/mpi-io/open.c
index 27a3e84..a2a68c9 100644
--- a/src/mpi/romio/mpi-io/open.c
+++ b/src/mpi/romio/mpi-io/open.c
@@ -179,7 +179,9 @@ int MPI_File_open(MPI_Comm comm, ROMIO_CONST char *filename, int amode,
     if ((error_code == MPI_SUCCESS) && 
 		    ADIO_Feature((*fh), ADIO_SHARED_FP)) {
 	MPI_Comm_rank(dupcomm, &rank);
-	ADIOI_Shfp_fname(*fh, rank);
+	ADIOI_Shfp_fname(*fh, rank, &error_code);
+	if (error_code != MPI_SUCCESS)
+	    goto fn_fail;
 
         /* if MPI_MODE_APPEND, set the shared file pointer to end of file.
            indiv. file pointer already set to end of file in ADIO_Open. 

-----------------------------------------------------------------------

Summary of changes:
 src/mpi/romio/adio/common/ad_fstype.c    |    4 --
 src/mpi/romio/adio/common/shfp_fname.c   |   46 ++++++++++++++++++++++-------
 src/mpi/romio/adio/common/system_hints.c |    4 --
 src/mpi/romio/adio/include/adioi.h       |    8 ++++-
 src/mpi/romio/mpi-io/open.c              |    4 ++-
 5 files changed, 45 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
MPICH primary repository


More information about the commits mailing list