[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#562176: luatex: FTBFS on hurd-i386: unconditional PATH_MAX usage



Package: luatex
Version: 0.47.0-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

Hi,

currently[1] luatex does not build on GNU/Hurd.
The problem is the unconditional usage of PATH_MAX.
The attached patch solves the issue, malloc'ing the buffers as needed.
It also adds a small bit to "recognize" the GNU platform.

[1] https://buildd.debian.org/fetch.cgi?pkg=luatex&arch=hurd-i386&ver=0.47.0-1&stamp=1261470395&file=log&as=raw

Thanks,
-- 
Pino
--- a/source/texk/web2c/luatexdir/lua/loslibext.c
+++ b/source/texk/web2c/luatexdir/lua/loslibext.c
@@ -81,6 +81,9 @@
 #  elif defined(__MACH__) && defined(__APPLE__)
 #    undef OS_PLATNAME
 #    define OS_PLATNAME "macosx"
+#  elif defined(__GNU__)
+#    undef OS_PLATNAME
+#    define OS_PLATNAME "gnu"
 #  endif
 #endif
 
@@ -117,7 +120,7 @@
 
 static int exec_command(const char *file, char *const *argv, char *const *envp)
 {
-    char path[PATH_MAX];
+    char *path;
     const char *searchpath, *esp;
     size_t prefixlen, filelen, totallen;
 
@@ -125,6 +128,7 @@
         return execve(file, argv, envp);
 
     filelen = strlen(file);
+    path = NULL;
 
     searchpath = getenv("PATH");
     if (!searchpath)
@@ -141,14 +145,20 @@
 
         if (prefixlen == 0 || searchpath[prefixlen - 1] == '/') {
             totallen = prefixlen + filelen;
+#ifdef PATH_MAX
             if (totallen >= PATH_MAX)
                 continue;
+#endif
+            path = malloc(totallen + 1);
             memcpy(path, searchpath, prefixlen);
             memcpy(path + prefixlen, file, filelen);
         } else {
             totallen = prefixlen + filelen + 1;
+#ifdef PATH_MAX
             if (totallen >= PATH_MAX)
                 continue;
+#endif
+            path = malloc(totallen + 1);
             memcpy(path, searchpath, prefixlen);
             path[prefixlen] = '/';
             memcpy(path + prefixlen + 1, file, filelen);
@@ -156,6 +166,8 @@
         path[totallen] = '\0';
 
         execve(path, argv, envp);
+        free(path);
+        path = NULL;
         if (errno == E2BIG || errno == ENOEXEC ||
             errno == ENOMEM || errno == ETXTBSY)
             break;              /* Report this as an error, no more search */

Reply to: