]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Check length of synth-domain prefix.
authorSimon Kelley <simon@thekelleys.org.uk>
Thu, 25 Apr 2013 10:03:47 +0000 (11:03 +0100)
committerSimon Kelley <simon@thekelleys.org.uk>
Thu, 25 Apr 2013 10:03:47 +0000 (11:03 +0100)
src/config.h
src/option.c

index e412007f8184061fbfe8d1dd91c219388e35b797..5224adf8e33c912d49394b77d31809a9725c7ebd 100644 (file)
@@ -279,12 +279,12 @@ HAVE_SOCKADDR_SA_LEN
 #if defined(INET6_ADDRSTRLEN) && defined(IPV6_V6ONLY)
 #  define HAVE_IPV6
 #  define ADDRSTRLEN INET6_ADDRSTRLEN
-#elif defined(INET_ADDRSTRLEN)
-#  undef HAVE_IPV6
-#  define ADDRSTRLEN INET_ADDRSTRLEN
 #else
+#  if !defined(INET_ADDRSTRLEN)
+#      define INET_ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */
+#  endif
 #  undef HAVE_IPV6
-#  define ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */
+#  define ADDRSTRLEN INET_ADDRSTRLEN
 #endif
 
 
index 77d9db588b50ecb05a5226bbbfd90eccc999f021..20a8668273d4cc2825751eb3a05b5f52d17be6f8 100644 (file)
@@ -1726,7 +1726,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
                          if (arg)
                            {
                              if (option != 's')
-                               new->prefix = canonicalise_opt(arg);
+                               {
+                                 if (!(new->prefix = canonicalise_opt(arg)) ||
+                                     strlen(new->prefix) > MAXLABEL - INET_ADDRSTRLEN)
+                                   ret_err(_("bad prefix"));
+                               }
                              else if (strcmp(arg, "local") != 0 ||
                                       (msize != 8 && msize != 16 && msize != 24))
                                ret_err(gen_err);
@@ -1783,7 +1787,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
                          else if (arg)
                            {
                              if (option != 's')
-                               new->prefix = canonicalise_opt(arg);
+                               {
+                                 if (!(new->prefix = canonicalise_opt(arg)) ||
+                                     strlen(new->prefix) > MAXLABEL - INET6_ADDRSTRLEN)
+                                   ret_err(_("bad prefix"));
+                               }       
                              else if (strcmp(arg, "local") != 0 || ((msize & 4) != 0))
                                ret_err(gen_err);
                              else