Package: nss Version: 3.12.4-1 Severity: important Tags: patch User: [email protected] Usertags: hurd
Hi, as shown in [1], nss fails to build because of unconditional usage of PATH_MAX. There is already a patch (38_hurd.dpatch) fixing the same issue in another source file, so I'm attaching a new version with the fixes for mozilla/security/nss/lib/freebl/unix_rand.c. [1] https://buildd.debian.org/fetch.cgi?pkg=nss&arch=hurd-i386&ver=3.12.4-1&stamp=1255226426&file=log&as=raw Thanks, -- Pino -- System Information: Debian Release: squeeze/sid APT prefers testing APT policy: (850, 'testing'), (800, 'unstable'), (750, 'experimental'), (750, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 2.6.30-2-amd64 (SMP w/2 CPU cores) Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash
#! /bin/sh /usr/share/dpatch/dpatch-run ## 38_hurd.dpatch by <[email protected]>, Pino Toscano <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Fix FTBFS on Hurd because of MAXPATHLEN @DPATCH@ diff --git a/mozilla/security/nss/cmd/shlibsign/shlibsign.c b/mozilla/security/nss/cmd/shlibsign/shlibsign.c index 6e93225..6ca8606 100644 --- a/mozilla/security/nss/cmd/shlibsign/shlibsign.c +++ b/mozilla/security/nss/cmd/shlibsign/shlibsign.c @@ -594,7 +594,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 @@ -871,10 +870,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); --- a/mozilla/security/nss/lib/freebl/unix_rand.c +++ b/mozilla/security/nss/lib/freebl/unix_rand.c @@ -1058,15 +1058,30 @@ ReadFileOK(char *dir, char *file) { struct stat stat_buf; - char filename[PATH_MAX]; - int count = snprintf(filename, sizeof filename, "%s/%s",dir, file); + char *filename; + int dir_len = strlen(dir); + int count = dir_len + 1 + strlen(file) + 1; - if (count <= 0) { +#ifdef PATH_MAX + if (count >= PATH_MAX) { return PR_FALSE; /* name too long, can't read it anyway */ } +#endif + + filename = malloc(count); + if (filename == NULL) { + return PR_FALSE; /* cannot allocate that much memory */ + } + if (snprintf(filename, count, "%s/%s", dir, file) <= 0) { + free(filename); + return PR_FALSE; + } - if (stat(filename, &stat_buf) < 0) + if (stat(filename, &stat_buf) < 0) { + free(filename); return PR_FALSE; /* can't stat, probably can't read it then as well */ + } + free(filename); return S_ISREG(stat_buf.st_mode) ? PR_TRUE : PR_FALSE; } @@ -1131,11 +1146,20 @@ } if (error == 0) { - char filename[PATH_MAX]; - int count = snprintf(filename, sizeof filename, - "%s/%s",dir, &entry_dir.d_name[0]); - if (count >= 1) { - ReadSingleFile(filename); + char *filename; + int dir_len = strlen(dir); + int count = dir_len + 1 + strlen(&entry_dir.d_name[0]) + 1; +#ifdef PATH_MAX + if (count < PATH_MAX) +#endif + { + filename = malloc(count); + if (filename != NULL) { + if (snprintf(filename, count, "%s/%s", dir, &entry_dir.d_name[0]) > 0) { + ReadSingleFile(filename); + } + free(filename); + } } }

