nss_db: Fix initialization of iteration position (#1344480)

This commit is contained in:
Florian Weimer 2016-08-18 16:12:58 +02:00
parent 18df09c331
commit fe01d7c362
2 changed files with 46 additions and 0 deletions

43
glibc-rh1344480.patch Normal file
View File

@ -0,0 +1,43 @@
commit 809cde4a640032f2f87319c9358be4fee8d6d7d5
Author: Florian Weimer <fweimer@redhat.com>
Date: Sat Jun 11 12:12:56 2016 +0200
nss_db: Fix initialization of iteration position [BZ #20237]
When get*ent is called without a preceding set*ent, we need
to set the initial iteration position in get*ent.
Reproducer: Add “services: db files” to /etc/nsswitch.conf, then run
“perl -e getservent”. It will segfault before this change, and exit
silently after it.
(cherry picked from commit 31d0a4fa646db8b8c97ce24e0ec0a7b73de4fca1)
diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c
index 4a0766a..70b58be 100644
--- a/nss/nss_db/db-XXX.c
+++ b/nss/nss_db/db-XXX.c
@@ -77,7 +77,7 @@ CONCAT(_nss_db_set,ENTNAME) (int stayopen)
keep_db |= stayopen;
/* Reset the sequential index. */
- entidx = (const char *) state.header + state.header->valstroffset;
+ entidx = NULL;
}
__libc_lock_unlock (lock);
@@ -253,8 +253,14 @@ CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer,
H_ERRNO_SET (NETDB_INTERNAL);
goto out;
}
+ entidx = NULL;
}
+ /* Start from the beginning if freshly initialized or reset
+ requested by set*ent. */
+ if (entidx == NULL)
+ entidx = (const char *) state.header + state.header->valstroffset;
+
status = NSS_STATUS_UNAVAIL;
if (state.header != MAP_FAILED)
{

View File

@ -275,6 +275,7 @@ Patch1054: glibc-rh1352625.patch
Patch1055: glibc-rh1348620.patch
Patch1056: glibc-swbz20435.patch
Patch1057: glibc-rh1294574.patch
Patch1058: glibc-rh1344480.patch
##############################################################################
#
@ -749,6 +750,7 @@ microbenchmark tests on the system.
%patch1055 -p1
%patch1056 -p1
%patch1057 -p1
%patch1058 -p1
%patch0059 -p1
##############################################################################
@ -1975,6 +1977,7 @@ rm -f *.filelist*
- malloc: Avoid premature fallback to mmap (#1348620)
- CVE-2016-6323: Backtraces can hang on ARM EABI (32-bit) (swbz#20435)
- Return proper status from _nss_nis_initgroups_dyn (#1294574)
- nss_db: Fix initialization of iteration position (#1344480)
* Thu Jun 2 2016 Florian Weimer <fweimer@redhat.com> - 2.22-17
- CVE-2016-4429: stack overflow in Sun RPC clntudp_call (#1337140)