]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
check that order is non NULL before calling strtok_r
authorMark Andrews <marka@isc.org>
Tue, 1 May 2018 05:52:35 +0000 (15:52 +1000)
committerOndřej Surý <ondrej@isc.org>
Thu, 3 May 2018 15:08:59 +0000 (11:08 -0400)
lib/irs/getaddrinfo.c

index ed62c391b6f944eb92ef66c98b816762f5fdd6df..e67f9bbbfed23029f79b67f2b2a906eb76d9df4f 100644 (file)
@@ -9,8 +9,6 @@
  * information regarding copyright ownership.
  */
 
-/* $Id: getaddrinfo.c,v 1.3 2009/09/02 23:48:02 tbox Exp $ */
-
 /*! \file */
 
 /**
@@ -1070,22 +1068,24 @@ set_order(int family, int (**net_order)(const char *, int, struct addrinfo **,
        } else {
                order = getenv("NET_ORDER");
                found = 0;
-               last = NULL;
-               for (tok = strtok_r(order, ":", &last);
-                    tok;
-                    tok = strtok_r(NULL, ":", &last))
-               {
-                       if (strcasecmp(tok, "inet6") == 0) {
-                               if ((found & FOUND_IPV6) == 0) {
-                                       *net_order++ = add_ipv6;
-                               }
-                               found |= FOUND_IPV6;
-                       } else if (strcasecmp(tok, "inet") == 0 ||
-                                  strcasecmp(tok, "inet4") == 0) {
-                               if ((found & FOUND_IPV4) == 0) {
-                                       *net_order++ = add_ipv4;
+               if (order != NULL) {
+                       last = NULL;
+                       for (tok = strtok_r(order, ":", &last);
+                            tok;
+                            tok = strtok_r(NULL, ":", &last))
+                       {
+                               if (strcasecmp(tok, "inet6") == 0) {
+                                       if ((found & FOUND_IPV6) == 0) {
+                                               *net_order++ = add_ipv6;
+                                       }
+                                       found |= FOUND_IPV6;
+                               } else if (strcasecmp(tok, "inet") == 0 ||
+                                          strcasecmp(tok, "inet4") == 0) {
+                                       if ((found & FOUND_IPV4) == 0) {
+                                               *net_order++ = add_ipv4;
+                                       }
+                                       found |= FOUND_IPV4;
                                }
-                               found |= FOUND_IPV4;
                        }
                }