From b5a7ff42bbdd69458738e4d90f754baffd6f3b7c Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Thu, 25 Apr 2013 11:03:47 +0100 Subject: [PATCH] Check length of synth-domain prefix. --- src/config.h | 8 ++++---- src/option.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/config.h b/src/config.h index e412007..5224adf 100644 --- a/src/config.h +++ b/src/config.h @@ -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) +#else +# if !defined(INET_ADDRSTRLEN) +# define INET_ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */ +# endif # undef HAVE_IPV6 # define ADDRSTRLEN INET_ADDRSTRLEN -#else -# undef HAVE_IPV6 -# define ADDRSTRLEN 16 /* 4*3 + 3 dots + NULL */ #endif diff --git a/src/option.c b/src/option.c index 77d9db5..20a8668 100644 --- a/src/option.c +++ b/src/option.c @@ -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