Package: globus-common
Severity: important
Tags: patch

Hello,

globus-common currently FTBFS on hurd-i386 because it makes an
unconditional use of PATH_MAX, while POSIX says such limit is optional,
and it happens that hurd-i386 doesn't have such limitation.

Barry deFreese wrote a patch to fix this, attached to this mail, could
you please apply it?

Thanks
Samuel

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.29 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

-- 
Samuel Thibault <[email protected]>
<y> muhahaha...
<y> ya un train qui part de Perrache � 14h57
<y> qui passe � Part-Dieu � 15h10
<y> si je le prend � Perrache, je suis en zone bleue
<y> si je le prends � Part-Dieu, je suis en zone blanche
<y> donc je vais le prendre � Perrache *mais* � Part-Dieu ;-)
 -+- #ens-mim - vive la SNCF -+-
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 
05:54:14.000000000 +0000
+++ globus-common-10.2/library/globus_common.h.in       2009-06-02 
17:12:58.000000000 +0000
@@ -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. */
Only in globus-common-10.2/library: globus_common.h.in.orig
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 
03:09:41.000000000 +0000
+++ globus-common-10.2/library/globus_libc.c    2009-06-02 17:15:48.000000000 
+0000
@@ -34,6 +34,8 @@
 #include "config.h"
 #include "globus_common.h"
 
+#include <stddef.h> /* For offsetof() */
+
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
@@ -46,11 +48,6 @@
 #include <arpa/inet.h>
 #endif
 
-#if !defined(MAXPATHLEN)
-#   include <sys/param.h>
-#   define MAXPATHLEN PATH_MAX
-#endif
-
 /* HPUX 10.20 headers do not define this */
 #if defined(TARGET_ARCH_HPUX)
 extern int h_errno;
@@ -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,7 @@
            if (!rc && p)
            {
                len = strlen(p);
-               if (len+1 < MAXPATHLEN)
+               if ((homedir = malloc(len+1) != NULL))
                {
                    memcpy(homedir, p, len);
                    homedir[len] = '\0';
@@ -2556,9 +2553,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 +2564,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 +2615,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 +2630,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;
 
Only in globus-common-10.2/library: globus_libc.c.orig

Reply via email to