Don't alloc struct iface_struct nics[MAX_INTERFACES]; (128 entries)
authorJeremy Allison <jra@samba.org>
Mon, 5 Nov 2007 06:20:04 +0000 (22:20 -0800)
committerJeremy Allison <jra@samba.org>
Mon, 5 Nov 2007 06:20:04 +0000 (22:20 -0800)
on the stack - use talloc.
Jeremy
(This used to be commit b5e37af251a26648b0e4f59ca548c5374399175e)

source3/lib/util_sock.c

index d87d954536444932be1e80afd07bc25bb61c62e3..02097239cfbba262d74158f8910b71af0eab9c98 100644 (file)
@@ -2082,7 +2082,7 @@ bool is_myname_or_ipaddr(const char *s)
        /* Maybe its an IP address? */
        if (is_ipaddress(servername)) {
                struct sockaddr_storage ss;
-               struct iface_struct nics[MAX_INTERFACES];
+               struct iface_struct *nics;
                int i, n;
 
                if (!interpret_string_addr(&ss, servername, AI_NUMERICHOST)) {
@@ -2093,12 +2093,19 @@ bool is_myname_or_ipaddr(const char *s)
                        return false;
                }
 
+               nics = TALLOC_ARRAY(talloc_tos(), struct iface_struct,
+                                       MAX_INTERFACES);
+               if (!nics) {
+                       return false;
+               }
                n = get_interfaces(nics, MAX_INTERFACES);
                for (i=0; i<n; i++) {
                        if (addr_equal(&nics[i].ip, &ss)) {
+                               TALLOC_FREE(nics);
                                return true;
                        }
                }
+               TALLOC_FREE(nics);
        }
 
        /* No match */