Fix FTBFS on Hurd because of MAXPATHLEN
authorMike Hommey <mh@glandium.org>
Mon, 13 Jan 2014 03:00:25 +0000 (12:00 +0900)
committerMike Hommey <glandium@debian.org>
Sun, 14 Feb 2016 09:25:51 +0000 (09:25 +0000)
Gbp-Pq: Topic porting
Gbp-Pq: Name NSS-Fix-FTBFS-on-Hurd-because-of-MAXPATHLEN.patch

security/nss/cmd/shlibsign/shlibsign.c
security/nss/lib/freebl/unix_rand.c

index 7ddbf343dfe6cb71e889e370a92e533eec7ce853..48e1aae3172fa98a4f2514cd3fdc475bee3fbbd1 100644 (file)
@@ -716,7 +716,6 @@ int main(int argc, char **argv)
 #ifdef USES_LINKS
     int ret;
     struct stat stat_buf;
-    char link_buf[MAXPATHLEN+1];
     char *link_file = NULL;
 #endif
 
@@ -1044,10 +1043,22 @@ int main(int argc, char **argv)
     }
     if (S_ISLNK(stat_buf.st_mode)) {
         char *dirpath,*dirend;
-        ret = readlink(input_file, link_buf, sizeof(link_buf) - 1);
-        if (ret < 0) {
-            perror(input_file);
-            goto cleanup;
+        char *link_buf = NULL;
+        size_t size = 64;
+        while (1) {
+            link_buf = realloc(link_buf, size);
+            if (!link_buf) {
+                perror(input_file);
+                goto cleanup;
+            }
+            ret = readlink(input_file, link_buf, size - 1);
+            if (ret < 0) {
+                perror(input_file);
+                goto cleanup;
+            }
+            if (ret < size - 1)
+                break;
+            size *= 2;
         }
         link_buf[ret] = 0;
         link_file = mkoutput(input_file);
index 579040eea8e25729f04d469c8f6be7dd9e3cc1de..b4fef7a08f9daa707e8ae461c73d420d0f36cbbc 100644 (file)
@@ -1031,6 +1031,10 @@ void ReadSingleFile(const char *fileName)
 #define _POSIX_PTHREAD_SEMANTICS
 #include <dirent.h>
 
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
 PRBool
 ReadFileOK(char *dir, char *file)
 {