[NSS] 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>
Tue, 13 Jul 2021 20:58:36 +0000 (21:58 +0100)
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 ad8f3b84eb10d4e535b372a2915d005bb2a96da1..c33f2c9cef3ea717b980a7723cef74dcfa4c0232 100644 (file)
@@ -725,7 +725,6 @@ main(int argc, char **argv)
 #ifdef USES_LINKS
     int ret;
     struct stat stat_buf;
-    char link_buf[MAXPATHLEN + 1];
     char *link_file = NULL;
 #endif
 
@@ -1068,10 +1067,22 @@ 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 24381cb26ed0819cc871379a528b780745ac1216..f5520f08b01da03cac55497c18f13481c7565d25 100644 (file)
@@ -843,6 +843,10 @@ RNG_FileForRNG(const char *fileName)
 #define _POSIX_PTHREAD_SEMANTICS
 #include <dirent.h>
 
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
 PRBool
 ReadFileOK(char *dir, char *file)
 {