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