]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Do not continue in nss_db_getservbyname
authorAlexandre Oliva <aoliva@redhat.com>
Mon, 3 Nov 2014 20:51:40 +0000 (18:51 -0200)
committerAlexandre Oliva <aoliva@redhat.com>
Fri, 7 Nov 2014 09:18:53 +0000 (07:18 -0200)
nss/nss_db/db-XXX.c
nss/nss_files/files-service.c

index 89b1a126c22ea5f4dc3bc4d0680c2bc5dfd7271e..e95088743dfa94cc4a9ce76532a8dc06d6549aa0 100644 (file)
@@ -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)                                         \
index 2401cb0852e03f74c9af4feb710a98ccd5fe9c6b..c28c62f94b1dfd2d8d29f11e1f9b55c265f78c3b 100644 (file)
@@ -44,8 +44,11 @@ DB_LOOKUP (servbyname, ':',
           {
             /* Must match both protocol (if specified) and name.  */
             if (proto != NULL && strcmp (result->s_proto, proto))
-              continue;
-            LOOKUP_NAME (s_name, s_aliases)
+              /* A continue statement here breaks nss_db, because it
+               bypasses advancing to the next db entry, and it
+               doesn't make nss_files any more efficient.  */;
+            else
+              LOOKUP_NAME (s_name, s_aliases)
           },
           const char *name, const char *proto)