5704bb9
diff -ur globus_common-10.2.orig/library/globus_common.h.in globus_common-10.2/library/globus_common.h.in
5704bb9
--- globus_common-10.2.orig/library/globus_common.h.in	2006-01-19 06:54:14.000000000 +0100
5704bb9
+++ globus_common-10.2/library/globus_common.h.in	2009-06-03 16:03:07.000000000 +0200
5704bb9
@@ -115,11 +115,6 @@
5704bb9
 #endif
5704bb9
 #endif
5704bb9
 
5704bb9
-#if !defined(MAXPATHLEN) 
5704bb9
-#   include <sys/param.h>
5704bb9
-#   define MAXPATHLEN PATH_MAX
5704bb9
-#endif
5704bb9
-
5704bb9
 /* most network-related functions (getpeername, getsockname,...) have
5704bb9
    an int* as argument, except AIX which uses size_t*. This will
5704bb9
    masquerade the difference. */
5704bb9
diff -ur globus_common-10.2.orig/library/globus_libc.c globus_common-10.2/library/globus_libc.c
5704bb9
--- globus_common-10.2.orig/library/globus_libc.c	2008-04-05 05:09:41.000000000 +0200
5704bb9
+++ globus_common-10.2/library/globus_libc.c	2009-06-03 16:39:35.000000000 +0200
5704bb9
@@ -46,10 +46,7 @@
5704bb9
 #include <arpa/inet.h>
5704bb9
 #endif
5704bb9
 
5704bb9
-#if !defined(MAXPATHLEN)
5704bb9
-#   include <sys/param.h>
5704bb9
-#   define MAXPATHLEN PATH_MAX
5704bb9
-#endif
5704bb9
+#include <stddef.h> /* For offsetof() */
5704bb9
 
5704bb9
 /* HPUX 10.20 headers do not define this */
5704bb9
 #if defined(TARGET_ARCH_HPUX)
5704bb9
@@ -2218,7 +2215,7 @@
5704bb9
     static globus_mutex_t   gethomedir_mutex;
5704bb9
     static int              initialized = GLOBUS_FALSE;
5704bb9
     static struct passwd    pw;
5704bb9
-    static char             homedir[MAXPATHLEN];
5704bb9
+    static char *           homedir;
5704bb9
     static int              homedir_len = 0;
5704bb9
     static char             buf[1024];
5704bb9
     int                     rc;
5704bb9
@@ -2258,7 +2255,8 @@
5704bb9
 	    if (!rc && p)
5704bb9
 	    {
5704bb9
 		len = strlen(p);
5704bb9
-		if (len+1 < MAXPATHLEN)
5704bb9
+		homedir = globus_malloc(len + 1);
5704bb9
+		if (homedir)
5704bb9
 		{
5704bb9
 		    memcpy(homedir, p, len);
5704bb9
 		    homedir[len] = '\0';
5704bb9
@@ -2556,9 +2554,6 @@
5704bb9
 	struct dirent *tmpdir, *entry;
5704bb9
 	int save_errno;
5704bb9
 
5704bb9
-	entry = (struct dirent *) globus_malloc(sizeof(struct dirent)
5704bb9
-						+ MAXPATHLEN
5704bb9
-						+ 1);
5704bb9
 	globus_libc_lock();
5704bb9
 
5704bb9
 	tmpdir = readdir(dirp);
5704bb9
@@ -2570,13 +2565,15 @@
5704bb9
 
5704bb9
 	    globus_libc_unlock();
5704bb9
 
5704bb9
-            globus_free(entry);
5704bb9
-
5704bb9
 	    errno = save_errno;
5704bb9
 
5704bb9
 	    return -1;
5704bb9
 	}
5704bb9
 
5704bb9
+	entry = (struct dirent *) globus_malloc(offsetof(struct dirent, d_name)
5704bb9
+						+ strlen(tmpdir->d_name)
5704bb9
+						+ 1);
5704bb9
+
5704bb9
 	/* copy returned buffer into data structure */
5704bb9
 	entry->d_ino = tmpdir->d_ino;
5704bb9
 #       if defined(GLOBUS_HAVE_DIRENT_OFF)
5704bb9
@@ -2619,8 +2616,8 @@
5704bb9
 #       if defined(GLOBUS_HAVE_READDIR_R_3)
5704bb9
 	{
5704bb9
 	    int rc = 0;
5704bb9
-	    struct dirent *entry = globus_malloc(sizeof(struct dirent)
5704bb9
-						 + MAXPATHLEN
5704bb9
+	    struct dirent *entry = globus_malloc(offsetof(struct dirent, d_name)
5704bb9
+						 + NAME_MAX
5704bb9
 						 + 1);
5704bb9
 
5704bb9
 	    rc = readdir_r(dirp, entry, result);
5704bb9
@@ -2634,8 +2631,8 @@
5704bb9
 	}
5704bb9
 #       elif defined(GLOBUS_HAVE_READDIR_R_2)
5704bb9
 	{
5704bb9
-	    struct dirent *entry = globus_malloc(sizeof(struct dirent)
5704bb9
-						 + MAXPATHLEN
5704bb9
+	    struct dirent *entry = globus_malloc(offsetof(struct dirent, d_name)
5704bb9
+						 + NAME_MAX
5704bb9
 						 + 1);
5704bb9
 	    int rc=0;
5704bb9