diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2014-11-21 03:29:56 -0200 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2014-11-21 03:29:56 -0200 |
commit | 4969890247d7d6a548f17641ed5a18f4b713d211 (patch) | |
tree | 26eeb456373435508696552d794f926f02f74701 /nss/nss_db | |
parent | 81959214868c9ac9e425fbf0fa3fd9135e207f7e (diff) | |
download | glibc-4969890247d7d6a548f17641ed5a18f4b713d211.tar.gz glibc-4969890247d7d6a548f17641ed5a18f4b713d211.tar.xz glibc-4969890247d7d6a548f17641ed5a18f4b713d211.zip |
BZ#14498: fix infinite loop in nss_db_getservbyname
nss_db uses nss_files code for services, but a continue on protocol mismatch that doesn't affect nss_files skipped the code that advanced to the next db entry. Any one of these changes would suffice to fix it, but fixing both makes them both safer to reuse elsewhere. for ChangeLog [BZ #14498] * NEWS: Fixed. * nss/nss_db/db-XXX.c (_nss_db_get##name##_r): Update hidx after parsing line but before break_if_match. * nss/nss_files/files-service (DB_LOOKUP): Don't "continue;" if there is a protocol mismatch.
Diffstat (limited to 'nss/nss_db')
-rw-r--r-- | nss/nss_db/db-XXX.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c index 89b1a126c2..e95088743d 100644 --- a/nss/nss_db/db-XXX.c +++ b/nss/nss_db/db-XXX.c @@ -191,6 +191,12 @@ enum nss_status \ char *p = memcpy (buffer, valstr, len); \ \ int err = parse_line (p, result, data, buflen, errnop EXTRA_ARGS); \ + \ + /* Advance before break_if_match, lest it uses continue to skip + to the next entry. */ \ + if ((hidx += hval2) >= header->dbs[i].hashsize) \ + hidx -= header->dbs[i].hashsize; \ + \ if (err > 0) \ { \ status = NSS_STATUS_SUCCESS; \ @@ -203,9 +209,6 @@ enum nss_status \ status = NSS_STATUS_TRYAGAIN; \ break; \ } \ - \ - if ((hidx += hval2) >= header->dbs[i].hashsize) \ - hidx -= header->dbs[i].hashsize; \ } \ \ if (status == NSS_STATUS_NOTFOUND) \ |