From bb3d2585625201b75552ee03aad64a15566dfda7 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 27 Jan 2009 22:57:50 +0000 Subject: [PATCH] Round up a few places where PATH_MAX was used instead of OMPI_PATH_MAX. Thanks to Andrea Iob for the bug report. This commit was SVN r20360. --- opal/include/opal_config_bottom.h | 3 +++ opal/util/path.c | 7 ++++--- orte/mca/plm/rsh/plm_rsh_component.c | 5 +++-- orte/tools/orterun/debuggers.c | 6 +++--- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/opal/include/opal_config_bottom.h b/opal/include/opal_config_bottom.h index 2802e0381a..9c0d47d1e1 100644 --- a/opal/include/opal_config_bottom.h +++ b/opal/include/opal_config_bottom.h @@ -318,6 +318,9 @@ typedef long long bool; * Maximum size of a filename path. */ #include +#ifdef HAVE_SYS_PARAM_H +#include +#endif #if defined(PATH_MAX) #define OMPI_PATH_MAX (PATH_MAX + 1) #elif defined(_POSIX_PATH_MAX) diff --git a/opal/util/path.c b/opal/util/path.c index 3ff3d18e75..020dcb8baa 100644 --- a/opal/util/path.c +++ b/opal/util/path.c @@ -9,6 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -330,8 +331,8 @@ char* opal_find_absolute_path( char* app_name ) if( opal_path_is_absolute(app_name) ) { /* already absolute path */ abs_app_name = app_name; } else if( '.' == app_name[0] ) { /* the app is in the current directory */ - char cwd[PATH_MAX], *pcwd; - pcwd = getcwd( cwd, PATH_MAX ); + char cwd[OMPI_PATH_MAX], *pcwd; + pcwd = getcwd( cwd, OMPI_PATH_MAX ); if( NULL == pcwd ) { /* too bad there is no way we can get the app absolute name */ return NULL; @@ -343,7 +344,7 @@ char* opal_find_absolute_path( char* app_name ) } if( NULL != abs_app_name ) { - char* resolved_path = (char*)malloc(PATH_MAX); + char* resolved_path = (char*)malloc(OMPI_PATH_MAX); #if !defined(__WINDOWS__) realpath( abs_app_name, resolved_path ); #else diff --git a/orte/mca/plm/rsh/plm_rsh_component.c b/orte/mca/plm/rsh/plm_rsh_component.c index dfb16c0d36..cadfb6c620 100644 --- a/orte/mca/plm/rsh/plm_rsh_component.c +++ b/orte/mca/plm/rsh/plm_rsh_component.c @@ -12,6 +12,7 @@ * Copyright (c) 2007 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -286,9 +287,9 @@ static char **search(const char* agent_list) int i, j; char *line, **lines = opal_argv_split(agent_list, ':'); char **tokens, *tmp; - char cwd[PATH_MAX]; + char cwd[OMPI_PATH_MAX]; - getcwd(cwd, PATH_MAX); + getcwd(cwd, OMPI_PATH_MAX); for (i = 0; NULL != lines[i]; ++i) { line = lines[i]; diff --git a/orte/tools/orterun/debuggers.c b/orte/tools/orterun/debuggers.c index 6a76d79400..e857cbab82 100644 --- a/orte/tools/orterun/debuggers.c +++ b/orte/tools/orterun/debuggers.c @@ -13,7 +13,7 @@ * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2007 Los Alamos National Security, LLC. All rights * reserved. - * Copyright (c) 2007-2008 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2007-2009 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -188,7 +188,7 @@ static int process(char *orig_line, char *basename, opal_cmd_line_t *cmd_line, int i; char *line, *full_line = strdup(orig_line); char *user_argv, *tmp, *tmp2, **tmp_argv, **executable; - char cwd[PATH_MAX]; + char cwd[OMPI_PATH_MAX]; bool used_num_procs = false; bool single_app = false; bool fail_needed_executable = false; @@ -317,7 +317,7 @@ static int process(char *orig_line, char *basename, opal_cmd_line_t *cmd_line, /* Can we find argv[0] in the path? */ - getcwd(cwd, PATH_MAX); + getcwd(cwd, OMPI_PATH_MAX); tmp = opal_path_findv((*new_argv)[0], X_OK, environ, cwd); if (NULL != tmp) { free(tmp);