r1248: Fix from Nick Wellnhofer <wellnhofer@aevum.de> to prevent
authorJeremy Allison <jra@samba.org>
Thu, 24 Jun 2004 23:27:00 +0000 (23:27 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:52:03 +0000 (10:52 -0500)
lp_interfaces() list from being corrupted.
Jeremy.

source/lib/interface.c

index 4d8010e31bc4e61e4019a624ddb129ea6e86f962..adf9ca34381e45d723450fe6cbf2b816e13d73db 100644 (file)
@@ -94,7 +94,7 @@ This handles the following different forms:
 4) ip/mask
 5) bcast/mask
 ****************************************************************************/
-static void interpret_interface(const char *token)
+static void interpret_interface(char *token)
 {
        struct in_addr ip, nmask;
        char *p;
@@ -130,9 +130,9 @@ static void interpret_interface(const char *token)
        }
 
        /* parse it into an IP address/netmasklength pair */
-       *p++ = 0;
-
+       *p = 0;
        ip = *interpret_addr2(token);
+       *p++ = '/';
 
        if (strlen(p) > 2) {
                nmask = *interpret_addr2(p);
@@ -207,7 +207,11 @@ void load_interfaces(void)
 
        if (ptr) {
                while (*ptr) {
-                       interpret_interface(*ptr);
+                       char *ptr_cpy = strdup(*ptr);
+                       if (ptr_cpy) {
+                               interpret_interface(ptr_cpy);
+                               free(ptr_cpy);
+                       }
                        ptr++;
                }
        }