1From f2a81382c851df975afe0457b6583f3e6cc579c1 Mon Sep 17 00:00:00 2001 2From: Mike Hommey <mh@glandium.org> 3Date: Mon, 13 Jan 2014 12:00:25 +0900 4Subject: [PATCH] Fix FTBFS on Hurd because of MAXPATHLEN 5 6--- 7 security/nss/cmd/shlibsign/shlibsign.c | 21 ++++++++++++++++----- 8 security/nss/lib/freebl/unix_rand.c | 4 ++++ 9 2 files changed, 20 insertions(+), 5 deletions(-) 10 11diff --git a/security/nss/cmd/shlibsign/shlibsign.c b/security/nss/cmd/shlibsign/shlibsign.c 12index 221d1e67ed..dbe63236a5 100644 13--- a/security/nss/cmd/shlibsign/shlibsign.c 14+++ b/security/nss/cmd/shlibsign/shlibsign.c 15@@ -725,7 +725,6 @@ main(int argc, char **argv) 16 #ifdef USES_LINKS 17 int ret; 18 struct stat stat_buf; 19- char link_buf[MAXPATHLEN + 1]; 20 char *link_file = NULL; 21 #endif 22 23@@ -1068,10 +1067,22 @@ main(int argc, char **argv) 24 } 25 if (S_ISLNK(stat_buf.st_mode)) { 26 char *dirpath, *dirend; 27- ret = readlink(input_file, link_buf, sizeof(link_buf) - 1); 28- if (ret < 0) { 29- perror(input_file); 30- goto cleanup; 31+ char *link_buf = NULL; 32+ size_t size = 64; 33+ while (1) { 34+ link_buf = realloc(link_buf, size); 35+ if (!link_buf) { 36+ perror(input_file); 37+ goto cleanup; 38+ } 39+ ret = readlink(input_file, link_buf, size - 1); 40+ if (ret < 0) { 41+ perror(input_file); 42+ goto cleanup; 43+ } 44+ if (ret < size - 1) 45+ break; 46+ size *= 2; 47 } 48 link_buf[ret] = 0; 49 link_file = mkoutput(input_file); 50diff --git a/security/nss/lib/freebl/unix_rand.c b/security/nss/lib/freebl/unix_rand.c 51index 24381cb26e..f5520f08b0 100644 52--- a/security/nss/lib/freebl/unix_rand.c 53+++ b/security/nss/lib/freebl/unix_rand.c 54@@ -843,6 +843,10 @@ RNG_FileForRNG(const char *fileName) 55 #define _POSIX_PTHREAD_SEMANTICS 56 #include <dirent.h> 57 58+#ifndef PATH_MAX 59+#define PATH_MAX 1024 60+#endif 61+ 62 PRBool 63 ReadFileOK(char *dir, char *file) 64 { 65