#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
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);
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