From 82cb193ae9a67936619472f2f5f1fad6f8c083883823b4890ca1f31c5cb0bfd4 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 30 Sep 2015 10:23:58 +0000 Subject: [PATCH] Accepting request 334938 from home:Andreas_Schwab:Factory - nss-files-long-lines-2.patch: Properly reread entry after failure in nss_files getent function (bsc#945779, BZ #18991) OBS-URL: https://build.opensuse.org/request/show/334938 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=416 --- glibc-testsuite.changes | 6 ++ glibc-testsuite.spec | 3 + glibc-utils.changes | 6 ++ glibc-utils.spec | 3 + glibc.changes | 6 ++ glibc.spec | 3 + nss-files-long-lines-2.patch | 164 +++++++++++++++++++++++++++++++++++ 7 files changed, 191 insertions(+) create mode 100644 nss-files-long-lines-2.patch diff --git a/glibc-testsuite.changes b/glibc-testsuite.changes index dbdb2f6..df4e7ef 100644 --- a/glibc-testsuite.changes +++ b/glibc-testsuite.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Sep 24 09:41:13 UTC 2015 - schwab@suse.de + +- nss-files-long-lines-2.patch: Properly reread entry after failure in + nss_files getent function (bsc#945779, BZ #18991) + ------------------------------------------------------------------- Wed Sep 16 10:21:43 UTC 2015 - schwab@suse.de diff --git a/glibc-testsuite.spec b/glibc-testsuite.spec index 2226f2e..022d1cf 100644 --- a/glibc-testsuite.spec +++ b/glibc-testsuite.spec @@ -256,6 +256,8 @@ Patch2006: ibm93x-redundant-shift-si.patch Patch2007: static-dlopen.patch # PATCH-FIX-UPSTREAM Fix fnmatch handling of collating elements (BZ #17396, BZ #16976) Patch2008: fnmatch-collating-elements.patch +# PATCH-FIX-UPSTREAM Properly reread entry after failure in nss_files getent function (BZ #18991) +Patch2009: nss-files-long-lines-2.patch # Non-glibc patches # PATCH-FIX-OPENSUSE Remove debianisms from manpages @@ -467,6 +469,7 @@ rm nscd/s-stamp %patch2006 -p1 %patch2007 -p1 %patch2008 -p1 +%patch2009 -p1 %patch3000 diff --git a/glibc-utils.changes b/glibc-utils.changes index dbdb2f6..df4e7ef 100644 --- a/glibc-utils.changes +++ b/glibc-utils.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Sep 24 09:41:13 UTC 2015 - schwab@suse.de + +- nss-files-long-lines-2.patch: Properly reread entry after failure in + nss_files getent function (bsc#945779, BZ #18991) + ------------------------------------------------------------------- Wed Sep 16 10:21:43 UTC 2015 - schwab@suse.de diff --git a/glibc-utils.spec b/glibc-utils.spec index a158a06..e17d5fe 100644 --- a/glibc-utils.spec +++ b/glibc-utils.spec @@ -255,6 +255,8 @@ Patch2006: ibm93x-redundant-shift-si.patch Patch2007: static-dlopen.patch # PATCH-FIX-UPSTREAM Fix fnmatch handling of collating elements (BZ #17396, BZ #16976) Patch2008: fnmatch-collating-elements.patch +# PATCH-FIX-UPSTREAM Properly reread entry after failure in nss_files getent function (BZ #18991) +Patch2009: nss-files-long-lines-2.patch # Non-glibc patches # PATCH-FIX-OPENSUSE Remove debianisms from manpages @@ -467,6 +469,7 @@ rm nscd/s-stamp %patch2006 -p1 %patch2007 -p1 %patch2008 -p1 +%patch2009 -p1 %patch3000 diff --git a/glibc.changes b/glibc.changes index dbdb2f6..df4e7ef 100644 --- a/glibc.changes +++ b/glibc.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Sep 24 09:41:13 UTC 2015 - schwab@suse.de + +- nss-files-long-lines-2.patch: Properly reread entry after failure in + nss_files getent function (bsc#945779, BZ #18991) + ------------------------------------------------------------------- Wed Sep 16 10:21:43 UTC 2015 - schwab@suse.de diff --git a/glibc.spec b/glibc.spec index 9db3c18..ae68e2a 100644 --- a/glibc.spec +++ b/glibc.spec @@ -256,6 +256,8 @@ Patch2006: ibm93x-redundant-shift-si.patch Patch2007: static-dlopen.patch # PATCH-FIX-UPSTREAM Fix fnmatch handling of collating elements (BZ #17396, BZ #16976) Patch2008: fnmatch-collating-elements.patch +# PATCH-FIX-UPSTREAM Properly reread entry after failure in nss_files getent function (BZ #18991) +Patch2009: nss-files-long-lines-2.patch # Non-glibc patches # PATCH-FIX-OPENSUSE Remove debianisms from manpages @@ -467,6 +469,7 @@ rm nscd/s-stamp %patch2006 -p1 %patch2007 -p1 %patch2008 -p1 +%patch2009 -p1 %patch3000 diff --git a/nss-files-long-lines-2.patch b/nss-files-long-lines-2.patch new file mode 100644 index 0000000..ec41f8a --- /dev/null +++ b/nss-files-long-lines-2.patch @@ -0,0 +1,164 @@ +Properly reread entry after failure in nss_files getent function (bug 18991) + + * nss/nss_files/files-XXX.c (position, need_reread): New + variables. + (CONCAT(_nss_files_set,ENTNAME)): Initialize them. + (CONCAT(_nss_files_get,ENTNAME_r)): Likewise. Reposition stream + if last call was uncessful. + * nss/nss_files/files-alias.c (position, need_reread): New + variables. + (_nss_files_setaliasent): Initialize them. + (_nss_files_getaliasent_r): Likewise. Reposition stream if last + call was uncessful. + +Index: glibc-2.19/nss/nss_files/files-XXX.c +=================================================================== +--- glibc-2.19.orig/nss/nss_files/files-XXX.c ++++ glibc-2.19/nss/nss_files/files-XXX.c +@@ -65,6 +65,10 @@ __libc_lock_define_initialized (static, + getXXbyYY operations all use their own stream. */ + + static FILE *stream; ++/* Position after the last sucessfully read entry. */ ++static fpos_t position; ++/* Whether we need to reread the last entry on the next call. */ ++static bool need_reread; + + /* Open database file if not already opened. */ + static enum nss_status +@@ -131,6 +135,15 @@ CONCAT(_nss_files_set,ENTNAME) (int stay + + status = internal_setent (&stream); + ++ if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0) ++ { ++ fclose (stream); ++ stream = NULL; ++ status = NSS_STATUS_UNAVAIL; ++ } ++ ++ need_reread = false; ++ + __libc_lock_unlock (lock); + + return status; +@@ -286,11 +299,42 @@ CONCAT(_nss_files_get,ENTNAME_r) (struct + status = internal_setent (&stream); + + __set_errno (save_errno); ++ ++ if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0) ++ { ++ fclose (stream); ++ stream = NULL; ++ status = NSS_STATUS_UNAVAIL; ++ } ++ need_reread = false; + } + + if (status == NSS_STATUS_SUCCESS) +- status = internal_getent (stream, result, buffer, buflen, errnop +- H_ERRNO_ARG EXTRA_ARGS_VALUE); ++ { ++ /* Reposition the stream if the last call was unsucessful. */ ++ if (need_reread) ++ { ++ if (fsetpos (stream, &position) < 0) ++ status = NSS_STATUS_UNAVAIL; ++ else ++ need_reread = false; ++ } ++ } ++ ++ if (status == NSS_STATUS_SUCCESS) ++ { ++ status = internal_getent (stream, result, buffer, buflen, errnop ++ H_ERRNO_ARG EXTRA_ARGS_VALUE); ++ ++ /* Remember this position if we were successful. If the ++ operation failed we give the user a chance to repeat the ++ operation (perhaps the buffer was too small). */ ++ if (status == NSS_STATUS_SUCCESS) ++ fgetpos (stream, &position); ++ else ++ /* We must make sure we reposition the stream the next call. */ ++ need_reread = true; ++ } + + __libc_lock_unlock (lock); + +Index: glibc-2.19/nss/nss_files/files-alias.c +=================================================================== +--- glibc-2.19.orig/nss/nss_files/files-alias.c ++++ glibc-2.19/nss/nss_files/files-alias.c +@@ -38,6 +38,10 @@ __libc_lock_define_initialized (static, + getXXbyYY operations all use their own stream. */ + + static FILE *stream; ++/* Position after the last sucessfully read entry. */ ++static fpos_t position; ++/* Whether we need to reread the last entry on the next call. */ ++static bool need_reread; + + + static enum nss_status +@@ -104,6 +108,15 @@ _nss_files_setaliasent (void) + + status = internal_setent (&stream); + ++ if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0) ++ { ++ fclose (stream); ++ stream = NULL; ++ status = NSS_STATUS_UNAVAIL; ++ } ++ ++ need_reread = false; ++ + __libc_lock_unlock (lock); + + return status; +@@ -388,7 +401,29 @@ _nss_files_getaliasent_r (struct aliasen + + /* Be prepared that the set*ent function was not called before. */ + if (stream == NULL) +- status = internal_setent (&stream); ++ { ++ status = internal_setent (&stream); ++ ++ if (status == NSS_STATUS_SUCCESS && fgetpos (stream, &position) < 0) ++ { ++ fclose (stream); ++ stream = NULL; ++ status = NSS_STATUS_UNAVAIL; ++ } ++ need_reread = false; ++ } ++ ++ if (status == NSS_STATUS_SUCCESS) ++ { ++ /* Reposition the stream if the last call way unsucessful. */ ++ if (need_reread) ++ { ++ if (fsetpos (stream, &position) < 0) ++ status = NSS_STATUS_UNAVAIL; ++ else ++ need_reread = false; ++ } ++ } + + if (status == NSS_STATUS_SUCCESS) + { +@@ -398,6 +433,12 @@ _nss_files_getaliasent_r (struct aliasen + do + status = get_next_alias (stream, NULL, result, buffer, buflen, errnop); + while (status == NSS_STATUS_RETURN); ++ ++ /* If we successfully read an entry remember this position. */ ++ if (status == NSS_STATUS_SUCCESS) ++ fgetpos (stream, &position); ++ else ++ need_reread = true; + } + + __libc_lock_unlock (lock);