|
|
147e83 |
commit 4969890247d7d6a548f17641ed5a18f4b713d211
|
|
|
147e83 |
Author: Alexandre Oliva <aoliva@redhat.com>
|
|
|
147e83 |
Date: Fri Nov 21 03:29:56 2014 -0200
|
|
|
147e83 |
|
|
|
147e83 |
BZ#14498: fix infinite loop in nss_db_getservbyname
|
|
|
147e83 |
|
|
|
147e83 |
nss_db uses nss_files code for services, but a continue on protocol
|
|
|
147e83 |
mismatch that doesn't affect nss_files skipped the code that advanced
|
|
|
147e83 |
to the next db entry. Any one of these changes would suffice to fix
|
|
|
147e83 |
it, but fixing both makes them both safer to reuse elsewhere.
|
|
|
147e83 |
|
|
|
147e83 |
for ChangeLog
|
|
|
147e83 |
|
|
|
147e83 |
[BZ #14498]
|
|
|
147e83 |
* NEWS: Fixed.
|
|
|
147e83 |
* nss/nss_db/db-XXX.c (_nss_db_get##name##_r): Update hidx
|
|
|
147e83 |
after parsing line but before break_if_match.
|
|
|
147e83 |
* nss/nss_files/files-service (DB_LOOKUP): Don't "continue;"
|
|
|
147e83 |
if there is a protocol mismatch.
|
|
|
147e83 |
|
|
|
147e83 |
Index: b/nss/nss_db/db-XXX.c
|
|
|
147e83 |
===================================================================
|
|
|
147e83 |
--- a/nss/nss_db/db-XXX.c
|
|
|
147e83 |
+++ b/nss/nss_db/db-XXX.c
|
|
|
147e83 |
@@ -190,6 +190,12 @@ enum nss_status \
|
|
|
147e83 |
char *p = memcpy (buffer, valstr, len); \
|
|
|
147e83 |
\
|
|
|
147e83 |
int err = parse_line (p, result, data, buflen, errnop EXTRA_ARGS); \
|
|
|
147e83 |
+ \
|
|
|
147e83 |
+ /* Advance before break_if_match, lest it uses continue to skip
|
|
|
147e83 |
+ to the next entry. */ \
|
|
|
147e83 |
+ if ((hidx += hval2) >= header->dbs[i].hashsize) \
|
|
|
147e83 |
+ hidx -= header->dbs[i].hashsize; \
|
|
|
147e83 |
+ \
|
|
|
147e83 |
if (err > 0) \
|
|
|
147e83 |
{ \
|
|
|
147e83 |
status = NSS_STATUS_SUCCESS; \
|
|
|
147e83 |
@@ -202,9 +208,6 @@ enum nss_status \
|
|
|
147e83 |
status = NSS_STATUS_TRYAGAIN; \
|
|
|
147e83 |
break; \
|
|
|
147e83 |
} \
|
|
|
147e83 |
- \
|
|
|
147e83 |
- if ((hidx += hval2) >= header->dbs[i].hashsize) \
|
|
|
147e83 |
- hidx -= header->dbs[i].hashsize; \
|
|
|
147e83 |
} \
|
|
|
147e83 |
\
|
|
|
147e83 |
if (status == NSS_STATUS_NOTFOUND) \
|
|
|
147e83 |
Index: b/nss/nss_files/files-service.c
|
|
|
147e83 |
===================================================================
|
|
|
147e83 |
--- a/nss/nss_files/files-service.c
|
|
|
147e83 |
+++ b/nss/nss_files/files-service.c
|
|
|
147e83 |
@@ -44,8 +44,11 @@ DB_LOOKUP (servbyname, ':',
|
|
|
147e83 |
{
|
|
|
147e83 |
/* Must match both protocol (if specified) and name. */
|
|
|
147e83 |
if (proto != NULL && strcmp (result->s_proto, proto))
|
|
|
147e83 |
- continue;
|
|
|
147e83 |
- LOOKUP_NAME (s_name, s_aliases)
|
|
|
147e83 |
+ /* A continue statement here breaks nss_db, because it
|
|
|
147e83 |
+ bypasses advancing to the next db entry, and it
|
|
|
147e83 |
+ doesn't make nss_files any more efficient. */;
|
|
|
147e83 |
+ else
|
|
|
147e83 |
+ LOOKUP_NAME (s_name, s_aliases)
|
|
|
147e83 |
},
|
|
|
147e83 |
const char *name, const char *proto)
|
|
|
147e83 |
|