nss: fix compilation with glibc-2.24
PATCH 1/1 nss: fix compilation with glibc-2.24
readdir_r is deprecated as of glibc-2.24 and leads to a compilation error:
| In file included from sysrand.c:16:0: | unix_rand.c: In function 'ReadOneFile': | unix_rand.c:1090:6: error: 'readdir_r' is deprecated [-Werror=deprecated-declarations] | error = readdir_r(fd, &entry_dir, &result); | ^~~~~ | In file included from unix_rand.c:1032:0, | from sysrand.c:16: | /usr/include/dirent.h:183:12: note: declared here | extern int readdir_r (DIR *__restrict __dirp, | ^~~~~~~~~ | cc1: all warnings being treated as errors
The issue is reported in nss bug tracker
(https://bugzilla.mozilla.org/show_bug.cgi?id=1254334) and fixed in nss mainline.
The fixing patch is extracted from the nss source code repository.
--- .../nss/nss/use-readdir-instead-of-readdir_r.patch | 95 ++++++++++++++++++++++ meta/recipes-support/nss/nss_3.21.bb | 1 + 2 files changed, 96 insertions(+) create mode 100644 meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch
meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch new file +95 -0
@@ -0,0 +1,95 @@ +# HG changeset patch +# User Martin Thomson <[email protected]> +# Date 1457600884 -39600 +# Thu Mar 10 20:08:04 2016 +1100 +# Node ID 7309fcbce2eceae1e4e3c687348e540905ae286a +# Parent e7b6fca4f01427cafb4328f6e279af62290a2f34 +Bug 1254334 - Use readdir instead of readdir_r, r=emaldona, sr=rrelyea + +diff -r e7b6fca4f014 -r 7309fcbce2ec lib/freebl/unix_rand.c +--- a/nss/lib/freebl/unix_rand.c Wed Apr 20 15:22:46 2016 +0200 ++++ b/nss/lib/freebl/unix_rand.c Thu Mar 10 20:08:04 2016 +1100 +@@ -1054,26 +1054,16 @@ + * + * return 1 if it's time to reset the fileToRead (no more files to read). + */ +-int ReadOneFile(int fileToRead) ++static int ++ReadOneFile(int fileToRead) + { + char *dir = "/etc"; + DIR *fd = opendir(dir); + int resetCount = 0; +-#ifdef SOLARIS +- /* grumble, Solaris does not define struct dirent to be the full length */ +- typedef union { +- unsigned char space[sizeof(struct dirent) + MAXNAMELEN]; +- struct dirent dir; +- } dirent_hack; +- dirent_hack entry, firstEntry; +- +-#define entry_dir entry.dir +-#else +- struct dirent entry, firstEntry; +-#define entry_dir entry +-#endif +- +- int i, error = -1; ++ struct dirent *entry; ++ char firstName[NAME_MAX + 1]; ++ const char *name = NULL; ++ int i; + + if (fd == NULL) { + dir = PR_GetEnvSecure("HOME"); +@@ -1085,33 +1075,34 @@ + return 1; + } + ++ firstName[0] = '\0'; + for (i=0; i <= fileToRead; i++) { +- struct dirent *result = NULL; + do { +- error = readdir_r(fd, &entry_dir, &result); +- } while (error == 0 && result != NULL && +- !ReadFileOK(dir,&result->d_name[0])); +- if (error != 0 || result == NULL) { ++ /* readdir() isn't guaranteed to be thread safe on every platform; ++ * this code assumes the same directory isn't read concurrently. ++ * This usage is confirmed safe on Linux, see bug 1254334. */ ++ entry = readdir(fd); ++ } while (entry != NULL && !ReadFileOK(dir, &entry->d_name[0])); ++ if (entry == NULL) { + resetCount = 1; /* read to the end, start again at the beginning */ +- if (i != 0) { ++ if (firstName[0]) { + /* ran out of entries in the directory, use the first one */ +- entry = firstEntry; +- error = 0; +- break; ++ name = firstName; + } +- /* if i== 0, there were no readable entries in the directory */ + break; + } +- if (i==0) { +- /* save the first entry in case we run out of entries */ +- firstEntry = entry; ++ name = entry->d_name; ++ if (i == 0) { ++ /* copy the name of the first in case we run out of entries */ ++ PORT_Assert(PORT_Strlen(name) <= NAME_MAX); ++ PORT_Strncpy(firstName, name, NAME_MAX); ++ firstName[NAME_MAX] = '\0'; + } + } + +- if (error == 0) { ++ if (name) { + char filename[PATH_MAX]; +- int count = snprintf(filename, sizeof filename, +- "%s/%s",dir, &entry_dir.d_name[0]); ++ int count = snprintf(filename, sizeof(filename), "%s/%s",dir, name); + if (count >= 1) { + ReadSingleFile(filename); + }
meta/recipes-support/nss/nss_3.21.bb +1 -0
@@ -21,6 +21,7 @@ SRC_URI = "\ file://nss-fix-incorrect-shebang-of-perl.patch \ file://nss-fix-nsinstall-build.patch \ file://0001-Fix-build-failure-on-opensuse-13.1.patch \ + file://use-readdir-instead-of-readdir_r.patch \ file://nss-gcc6-fix.patch \ file://nss.pc.in \ file://signlibs.sh \
Signature · 1 line
2.9.3
Enrico,
Quoted 33 lines · Enrico Jorns
readdir_ris deprecated as of glibc-2.24 and leads to a compilation error:| In file included from sysrand.c:16:0: | unix_rand.c: In function 'ReadOneFile': | unix_rand.c:1090:6: error: 'readdir_r' is deprecated [-Werror=deprecated-declarations] | error = readdir_r(fd, &entry_dir, &result); | ^~~~~ | In file included from unix_rand.c:1032:0, | from sysrand.c:16: | /usr/include/dirent.h:183:12: note: declared here | extern int readdir_r (DIR *__restrict __dirp, | ^~~~~~~~~ | cc1: all warnings being treated as errorsThe issue is reported in nss bug tracker
(https://bugzilla.mozilla.org/show_bug.cgi?id=1254334) and fixed in nss mainline.
The fixing patch is extracted from the nss source code repository.Signed-off-by Enrico Jorns <[email protected]>--- .../nss/nss/use-readdir-instead-of-readdir_r.patch | 95 ++++++++++++++++++++++ meta/recipes-support/nss/nss_3.21.bb | 1 + 2 files changed, 96 insertions(+)create mode 100644
meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patchmeta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch new file +0
-0
meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch line 7
Quoted 7 lines
meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch new file +7
-0@@ -0,0 +1,95 @@ +# HG changeset patch +# User Martin Thomson <[email protected]> +# Date 1457600884 -39600 +# Thu Mar 10 20:08:04 2016 +1100 +# Node ID 7309fcbce2eceae1e4e3c687348e540905ae286a +# Parent e7b6fca4f01427cafb4328f6e279af62290a2f34 +Bug 1254334 - Use readdir instead of readdir_r, r=emaldona, sr=rrelyea
The patch is missing the appropriate patch formating. I am expecting "Upstream-Status: blah" etc
http://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
- Armin
Quoted 100 lines
meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch new file +88
-0+ +diff -r e7b6fca4f014 -r 7309fcbce2ec lib/freebl/unix_rand.c +--- a/nss/lib/freebl/unix_rand.c Wed Apr 20 15:22:46 2016 +0200 ++++ b/nss/lib/freebl/unix_rand.c Thu Mar 10 20:08:04 2016 +1100 +@@ -1054,26 +1054,16 @@ + * + * return 1 if it's time to reset the fileToRead (no more files to read). + */ +-int ReadOneFile(int fileToRead) ++static int ++ReadOneFile(int fileToRead) + { + char *dir = "/etc"; + DIR *fd = opendir(dir); + int resetCount = 0; +-#ifdef SOLARIS +- /* grumble, Solaris does not define struct dirent to be the full length */ +- typedef union { +- unsigned char space[sizeof(struct dirent) + MAXNAMELEN]; +- struct dirent dir; +- } dirent_hack; +- dirent_hack entry, firstEntry; +- +-#define entry_dir entry.dir +-#else +- struct dirent entry, firstEntry; +-#define entry_dir entry +-#endif +- +- int i, error = -1; ++ struct dirent *entry; ++ char firstName[NAME_MAX + 1]; ++ const char *name = NULL; ++ int i; + + if (fd == NULL) { + dir = PR_GetEnvSecure("HOME"); +@@ -1085,33 +1075,34 @@ + return 1; + } + ++ firstName[0] = '\0'; + for (i=0; i <= fileToRead; i++) { +- struct dirent *result = NULL; + do { +- error = readdir_r(fd, &entry_dir, &result); +- } while (error == 0 && result != NULL && +- !ReadFileOK(dir,&result->d_name[0])); +- if (error != 0 || result == NULL) { ++ /* readdir() isn't guaranteed to be thread safe on every platform; ++ * this code assumes the same directory isn't read concurrently. ++ * This usage is confirmed safe on Linux, see bug 1254334. */ ++ entry = readdir(fd); ++ } while (entry != NULL && !ReadFileOK(dir, &entry->d_name[0])); ++ if (entry == NULL) { + resetCount = 1; /* read to the end, start again at the beginning */ +- if (i != 0) { ++ if (firstName[0]) { + /* ran out of entries in the directory, use the first one */ +- entry = firstEntry; +- error = 0; +- break; ++ name = firstName; + } +- /* if i== 0, there were no readable entries in the directory */ + break; + } +- if (i==0) { +- /* save the first entry in case we run out of entries */ +- firstEntry = entry; ++ name = entry->d_name; ++ if (i == 0) { ++ /* copy the name of the first in case we run out of entries */ ++ PORT_Assert(PORT_Strlen(name) <= NAME_MAX); ++ PORT_Strncpy(firstName, name, NAME_MAX); ++ firstName[NAME_MAX] = '\0'; + } + } + +- if (error == 0) { ++ if (name) { + char filename[PATH_MAX]; +- int count = snprintf(filename, sizeof filename, +- "%s/%s",dir, &entry_dir.d_name[0]); ++ int count = snprintf(filename, sizeof(filename), "%s/%s",dir, name); + if (count >= 1) { + ReadSingleFile(filename); + }meta/recipes-support/nss/nss_3.21.bb +1
-0@@ -21,6 +21,7 @@ SRC_URI = "\ file://nss-fix-incorrect-shebang-of-perl.patch \ file://nss-fix-nsinstall-build.patch \ file://0001-Fix-build-failure-on-opensuse-13.1.patch \ + file://use-readdir-instead-of-readdir_r.patch \ file://nss-gcc6-fix.patch \ file://nss.pc.in \ file://signlibs.sh \
PATCH v2 1/1 nss: fix compilation with glibc-2.24
readdir_r is deprecated as of glibc-2.24 and leads to a compilation error:
| In file included from sysrand.c:16:0: | unix_rand.c: In function 'ReadOneFile': | unix_rand.c:1090:6: error: 'readdir_r' is deprecated [-Werror=deprecated-declarations] | error = readdir_r(fd, &entry_dir, &result); | ^~~~~ | In file included from unix_rand.c:1032:0, | from sysrand.c:16: | /usr/include/dirent.h:183:12: note: declared here | extern int readdir_r (DIR *__restrict __dirp, | ^~~~~~~~~ | cc1: all warnings being treated as errors
The issue is reported in nss bug tracker
(https://bugzilla.mozilla.org/show_bug.cgi?id=1254334) and fixed in nss mainline.
The fixing patch is extracted from the nss source code repository.
---
Added missing upstream status.
.../nss/nss/use-readdir-instead-of-readdir_r.patch | 97 ++++++++++++++++++++++ meta/recipes-support/nss/nss_3.21.bb | 1 + 2 files changed, 98 insertions(+) create mode 100644 meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch
meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch new file +97 -0
@@ -0,0 +1,97 @@ +# HG changeset patch +# User Martin Thomson <[email protected]> +# Date 1457600884 -39600 +# Thu Mar 10 20:08:04 2016 +1100 +# Node ID 7309fcbce2eceae1e4e3c687348e540905ae286a +# Parent e7b6fca4f01427cafb4328f6e279af62290a2f34 +Bug 1254334 - Use readdir instead of readdir_r, r=emaldona, sr=rrelyea + +Upstream-Status: Backport + +diff -r e7b6fca4f014 -r 7309fcbce2ec lib/freebl/unix_rand.c +--- a/nss/lib/freebl/unix_rand.c Wed Apr 20 15:22:46 2016 +0200 ++++ b/nss/lib/freebl/unix_rand.c Thu Mar 10 20:08:04 2016 +1100 +@@ -1054,26 +1054,16 @@ + * + * return 1 if it's time to reset the fileToRead (no more files to read). + */ +-int ReadOneFile(int fileToRead) ++static int ++ReadOneFile(int fileToRead) + { + char *dir = "/etc"; + DIR *fd = opendir(dir); + int resetCount = 0; +-#ifdef SOLARIS +- /* grumble, Solaris does not define struct dirent to be the full length */ +- typedef union { +- unsigned char space[sizeof(struct dirent) + MAXNAMELEN]; +- struct dirent dir; +- } dirent_hack; +- dirent_hack entry, firstEntry; +- +-#define entry_dir entry.dir +-#else +- struct dirent entry, firstEntry; +-#define entry_dir entry +-#endif +- +- int i, error = -1; ++ struct dirent *entry; ++ char firstName[NAME_MAX + 1]; ++ const char *name = NULL; ++ int i; + + if (fd == NULL) { + dir = PR_GetEnvSecure("HOME"); +@@ -1085,33 +1075,34 @@ + return 1; + } + ++ firstName[0] = '\0'; + for (i=0; i <= fileToRead; i++) { +- struct dirent *result = NULL; + do { +- error = readdir_r(fd, &entry_dir, &result); +- } while (error == 0 && result != NULL && +- !ReadFileOK(dir,&result->d_name[0])); +- if (error != 0 || result == NULL) { ++ /* readdir() isn't guaranteed to be thread safe on every platform; ++ * this code assumes the same directory isn't read concurrently. ++ * This usage is confirmed safe on Linux, see bug 1254334. */ ++ entry = readdir(fd); ++ } while (entry != NULL && !ReadFileOK(dir, &entry->d_name[0])); ++ if (entry == NULL) { + resetCount = 1; /* read to the end, start again at the beginning */ +- if (i != 0) { ++ if (firstName[0]) { + /* ran out of entries in the directory, use the first one */ +- entry = firstEntry; +- error = 0; +- break; ++ name = firstName; + } +- /* if i== 0, there were no readable entries in the directory */ + break; + } +- if (i==0) { +- /* save the first entry in case we run out of entries */ +- firstEntry = entry; ++ name = entry->d_name; ++ if (i == 0) { ++ /* copy the name of the first in case we run out of entries */ ++ PORT_Assert(PORT_Strlen(name) <= NAME_MAX); ++ PORT_Strncpy(firstName, name, NAME_MAX); ++ firstName[NAME_MAX] = '\0'; + } + } + +- if (error == 0) { ++ if (name) { + char filename[PATH_MAX]; +- int count = snprintf(filename, sizeof filename, +- "%s/%s",dir, &entry_dir.d_name[0]); ++ int count = snprintf(filename, sizeof(filename), "%s/%s",dir, name); + if (count >= 1) { + ReadSingleFile(filename); + }
meta/recipes-support/nss/nss_3.21.bb +1 -0
@@ -21,6 +21,7 @@ SRC_URI = "\ file://nss-fix-incorrect-shebang-of-perl.patch \ file://nss-fix-nsinstall-build.patch \ file://0001-Fix-build-failure-on-opensuse-13.1.patch \ + file://use-readdir-instead-of-readdir_r.patch \ file://nss-gcc6-fix.patch \ file://nss.pc.in \ file://signlibs.sh \
Signature · 1 line
2.1.4