nwrap: Fix inventarization of IPs when loading hosts
authorMichael Adam <obnox@samba.org>
Thu, 12 Nov 2015 07:34:39 +0000 (08:34 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 11 Jan 2016 11:25:31 +0000 (12:25 +0100)
Use nwrap_ed_inventarize() instead of nwrap_add_ai().

This not only removes code duplication, but also
more correctly adds more than one line for a given
IP address in a list behind this address.

The original code would only have inventarized
the first line for an IP found.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/nss_wrapper/nss_wrapper.c

index ac38a48ae01259b8b27e5b84199f2f5cef716a79..0b57cbc62427ab3413ef115e1a75b4c8258747cf 100644 (file)
@@ -2567,35 +2567,6 @@ static struct nwrap_entlist *nwrap_entlist_init(struct nwrap_entdata *ed)
        return el;
 }
 
-static bool nwrap_add_ai(char *const ip_addr, struct nwrap_entdata *const ed)
-{
-       ENTRY e;
-       ENTRY *p;
-       struct nwrap_entlist *el;
-
-       if (ip_addr == NULL) {
-               NWRAP_LOG(NWRAP_LOG_ERROR, "ip_addr NULL - can't add");
-               return false;
-       }
-
-       el = nwrap_entlist_init(ed);
-       if (el == NULL) {
-               return false;
-       }
-
-       e.key = ip_addr;
-       e.data = el;
-
-       p = hsearch(e, ENTER);
-       if (p == NULL) {
-               NWRAP_LOG(NWRAP_LOG_ERROR, "Hash table is full");
-               return false;
-       }
-
-       return true;
-}
-
-
 static bool nwrap_ed_inventarize_add_new(char *const h_name,
                                         struct nwrap_entdata *const ed)
 {
@@ -2881,7 +2852,7 @@ static bool nwrap_he_parse_line(struct nwrap_cache *nwrap, char *line)
                return false;
        }
 
-       ok = nwrap_add_ai(ip, ed);
+       ok = nwrap_ed_inventarize(ip, ed);
        if (!ok) {
                return false;
        }