chiark / gitweb /
Fix typo in changelog entry for 1.6.1
[adns.git] / src / addrfam.c
index 528036c52fe75b9d8882b981b39baf119e7ef193..dece6e3d1ce1efeb578d314ed520cd7219e509da 100644 (file)
@@ -3,12 +3,8 @@
  * - address-family specific code
  */
 /*
- *  This file is part of adns, which is
- *    Copyright (C) 1997-2000,2003,2006,2014  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 file is part of adns, which is Copyright Ian Jackson
+ *  and contributors (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
@@ -256,9 +252,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 +271,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 +396,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;