X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Faddrfam.c;h=0ba204920529b980927374a75feca4bae51b389a;hb=7ba7a232de0516d2cce934bdc91627b33b46ef47;hp=4d2fe060c75c046400a5fe506958884031c02578;hpb=c0af047b137721acff216e6d5665433ff2a366cb;p=adns.git diff --git a/src/addrfam.c b/src/addrfam.c index 4d2fe06..0ba2049 100644 --- a/src/addrfam.c +++ b/src/addrfam.c @@ -4,14 +4,15 @@ */ /* * This file is part of adns, which is - * Copyright (C) 1997-2000,2003,2006 Ian Jackson + * Copyright (C) 1997-2000,2003,2006,2014-2016 Ian Jackson + * Copyright (C) 2014 Mark Wooding * Copyright (C) 1999-2000,2003,2006 Tony Finch * Copyright (C) 1991 Massachusetts Institute of Technology * (See the file INSTALL for full details.) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) + * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, @@ -20,8 +21,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program; if not, write to the Free Software Foundation. */ #include @@ -256,9 +256,18 @@ static bool addrtext_scope_use_ifname(const struct sockaddr *sa) { IN6_IS_ADDR_MC_LINKLOCAL(in6); } +static int textaddr_check_qf(adns_queryflags flags) { + if (flags & ~(adns_queryflags)(adns_qf_addrlit_scope_forbid| + adns_qf_addrlit_scope_numeric| + adns_qf_addrlit_ipv4_quadonly| + 0x40000000)) + return ENOSYS; + return 0; +} + int adns_text2addr(const char *text, uint16_t port, adns_queryflags flags, struct sockaddr *sa, socklen_t *salen_io) { - int af; + int r, af; char copybuf[INET6_ADDRSTRLEN]; const char *parse=text; const char *scopestr=0; @@ -266,6 +275,8 @@ int adns_text2addr(const char *text, uint16_t port, adns_queryflags flags, void *dst; uint16_t *portp; + r= textaddr_check_qf(flags); if (r) return r; + #define INVAL(how) do{ \ af_debug("invalid: %s: `%s'", how, text); \ return EINVAL; \ @@ -389,7 +400,9 @@ int adns_text2addr(const char *text, uint16_t port, adns_queryflags flags, int adns_addr2text(const struct sockaddr *sa, adns_queryflags flags, char *buffer, int *buflen_io, int *port_r) { const void *src; - int port; + int r, port; + + r= textaddr_check_qf(flags); if (r) return r; if (*buflen_io < ADNS_ADDR2TEXT_BUFLEN) { *buflen_io = ADNS_ADDR2TEXT_BUFLEN;