From: akuster808 <akuster808@gmail.com>
To: Enrico Jorns <ejo@pengutronix.de>,
openembedded-core@lists.openembedded.org
Subject: Re: [PATCH][krogoth] nss: fix compilation with glibc-2.24
Date: Tue, 1 Nov 2016 07:46:21 -0700 [thread overview]
Message-ID: <4b9e1364-53da-c237-276e-e2e011e13505@gmail.com> (raw)
In-Reply-To: <20161028060629.32357-1-ejo@pengutronix.de>
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 \
next prev parent reply other threads:[~2016-11-01 14:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-28 6:06 [PATCH][krogoth] nss: fix compilation with glibc-2.24 Enrico Jorns
2016-11-01 14:46 ` akuster808 [this message]
2016-11-08 15:07 ` [PATCH v2][krogoth] " Enrico Jorns
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4b9e1364-53da-c237-276e-e2e011e13505@gmail.com \
--to=akuster808@gmail.com \
--cc=ejo@pengutronix.de \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.