* [PATCH][krogoth] nss: fix compilation with glibc-2.24
@ 2016-10-28 6:06 Enrico Jorns
2016-11-01 14:46 ` akuster808
0 siblings, 1 reply; 3+ messages in thread
From: Enrico Jorns @ 2016-10-28 6:06 UTC (permalink / raw)
To: openembedded-core
`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.
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
.../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
diff --git a/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch b/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch
new file mode 100644
index 0000000..00f671f
--- /dev/null
+++ b/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch
@@ -0,0 +1,95 @@
+# HG changeset patch
+# User Martin Thomson <martin.thomson@gmail.com>
+# 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);
+ }
diff --git a/meta/recipes-support/nss/nss_3.21.bb b/meta/recipes-support/nss/nss_3.21.bb
index 05d81c2..39b0994 100644
--- a/meta/recipes-support/nss/nss_3.21.bb
+++ b/meta/recipes-support/nss/nss_3.21.bb
@@ -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 \
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH][krogoth] nss: fix compilation with glibc-2.24
2016-10-28 6:06 [PATCH][krogoth] nss: fix compilation with glibc-2.24 Enrico Jorns
@ 2016-11-01 14:46 ` akuster808
2016-11-08 15:07 ` [PATCH v2][krogoth] " Enrico Jorns
0 siblings, 1 reply; 3+ messages in thread
From: akuster808 @ 2016-11-01 14:46 UTC (permalink / raw)
To: Enrico Jorns, openembedded-core
Enrico,
On 10/27/2016 11:06 PM, Enrico Jorns wrote:
> `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.
>
> Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
> ---
> .../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
>
> diff --git a/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch b/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch
> new file mode 100644
> index 0000000..00f671f
> --- /dev/null
> +++ b/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch
> @@ -0,0 +1,95 @@
> +# HG changeset patch
> +# User Martin Thomson <martin.thomson@gmail.com>
> +# 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
> +
> +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);
> + }
> diff --git a/meta/recipes-support/nss/nss_3.21.bb b/meta/recipes-support/nss/nss_3.21.bb
> index 05d81c2..39b0994 100644
> --- a/meta/recipes-support/nss/nss_3.21.bb
> +++ b/meta/recipes-support/nss/nss_3.21.bb
> @@ -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 \
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v2][krogoth] nss: fix compilation with glibc-2.24
2016-11-01 14:46 ` akuster808
@ 2016-11-08 15:07 ` Enrico Jorns
0 siblings, 0 replies; 3+ messages in thread
From: Enrico Jorns @ 2016-11-08 15:07 UTC (permalink / raw)
To: openembedded-core; +Cc: Enrico Jorns
`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.
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
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
diff --git a/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch b/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch
new file mode 100644
index 0000000..226e57d
--- /dev/null
+++ b/meta/recipes-support/nss/nss/use-readdir-instead-of-readdir_r.patch
@@ -0,0 +1,97 @@
+# HG changeset patch
+# User Martin Thomson <martin.thomson@gmail.com>
+# 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);
+ }
diff --git a/meta/recipes-support/nss/nss_3.21.bb b/meta/recipes-support/nss/nss_3.21.bb
index 05d81c2..39b0994 100644
--- a/meta/recipes-support/nss/nss_3.21.bb
+++ b/meta/recipes-support/nss/nss_3.21.bb
@@ -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 \
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-08 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-28 6:06 [PATCH][krogoth] nss: fix compilation with glibc-2.24 Enrico Jorns
2016-11-01 14:46 ` akuster808
2016-11-08 15:07 ` [PATCH v2][krogoth] " Enrico Jorns
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox