chiark / gitweb /
adns.git
3 years agotimeout robustness: Track start time and duration
Ian Jackson [Sun, 5 Mar 2017 21:17:47 +0000 (21:17 +0000)]
timeout robustness: Track start time and duration

This allows us to detect if the clock rewinds, and restart our
timeouts from the new time.  Otherwise we might try to wait a very
long time.

The result is that clock instability may now produce spurious failures
of some queries, but it should no longer cause queries to be
indefinitely delayed.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agotimeout robustness: Introduce adns__timeout_{set,clear}
Ian Jackson [Fri, 9 Dec 2016 20:46:40 +0000 (20:46 +0000)]
timeout robustness: Introduce adns__timeout_{set,clear}

This abstracts away the open-coded handling of qu->timeout.
Rename the field to catch all call sites.

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoadnshost: Support --reverse in -f mode input stream
Ian Jackson [Sat, 10 Dec 2016 01:21:23 +0000 (01:21 +0000)]
adnshost: Support --reverse in -f mode input stream

Previously this would spuriously fail an assertion.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoRemove all m4 output files from the distributed source tree.
Ian Jackson [Sat, 19 Nov 2016 18:54:46 +0000 (18:54 +0000)]
Remove all m4 output files from the distributed source tree.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoclean targets: Delete $(TARGETS) too!
Ian Jackson [Sat, 19 Nov 2016 18:15:39 +0000 (18:15 +0000)]
clean targets: Delete $(TARGETS) too!

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoDocument 1.5.2 changes and set version number adns-1.5.2
Ian Jackson [Thu, 11 Jun 2020 14:58:55 +0000 (15:58 +0100)]
Document 1.5.2 changes and set version number

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoUpdate copyright dates everywhere
Ian Jackson [Thu, 11 Jun 2020 15:06:15 +0000 (16:06 +0100)]
Update copyright dates everywhere

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agointernal.h: Do not include spurious `data' symbol (!)
Ian Jackson [Tue, 26 May 2020 20:16:47 +0000 (21:16 +0100)]
internal.h: Do not include spurious `data' symbol (!)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoIf server sends answer with TC set via TCP, bail
Ian Jackson [Sun, 24 May 2020 17:16:07 +0000 (18:16 +0100)]
If server sends answer with TC set via TCP, bail

We shouldn't use the answer; it's corrupted.  But we don't have a
recovery strategy either.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoadns_finish: Cancel parent queries first
Ian Jackson [Fri, 16 Dec 2016 19:26:34 +0000 (19:26 +0000)]
adns_finish: Cancel parent queries first

Here, we should not cancel a query with a parent, because that leaves
the parent in a silly state (childw, but no children) which
adns__consistency complains about.

Instead, search upwards for a parent to cancel.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
3 years agoConsistency checks: Distinguish "entry" from exit
Ian Jackson [Sat, 10 Dec 2016 22:27:08 +0000 (22:27 +0000)]
Consistency checks: Distinguish "entry" from exit

Many externally-facing functions are called by adns itself.  In such a
case, on entry, there may be intdone queries in flight.  This is fine.

So distinguish cc_enter from cc_exit, and check intdone only on
cc_exit.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoFix binary compatibility of string conversion of RRs with internl addr tables
Ian Jackson [Sat, 10 Dec 2016 01:49:35 +0000 (01:49 +0000)]
Fix binary compatibility of string conversion of RRs with internl addr tables

Queries without adns__qtf_bigaddr use a smaller stride than the
size of our own adns_rr_addr.  This is dealt with by explicit
calculation of the addr struct using the stride from gsz_addr.

However, this circumlocution was omitted in cs_hostaddr, with the
result that adns_rr_info would go wrong for old clients.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agotypes.c: Pass real adns_rrtype to all cs_* functions and some csp_*
Ian Jackson [Sat, 10 Dec 2016 01:49:06 +0000 (01:49 +0000)]
types.c: Pass real adns_rrtype to all cs_* functions and some csp_*

No functional change yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoconsistency: Call adns__intdone_process in adns_afterpoll
Ian Jackson [Thu, 8 Dec 2016 19:32:37 +0000 (19:32 +0000)]
consistency: Call adns__intdone_process in adns_afterpoll

This avoids crashes if consistency checking is turned on.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoControl flow: Introduce adns__intdone_process
Ian Jackson [Thu, 8 Dec 2016 17:59:06 +0000 (17:59 +0000)]
Control flow: Introduce adns__intdone_process

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoDNS packet parsing: Slight fix when packet is truncated
Ian Jackson [Thu, 8 Dec 2016 18:58:40 +0000 (18:58 +0000)]
DNS packet parsing: Slight fix when packet is truncated

If the packet is truncated, adns__findrr_anychk returns adns_s_ok,
setting *type_r to -1.  It does not guarantee to set the other
outputs.

So, in pap_findaddrs, check for this first, rather than perhaps
reading the uninitialised `ownermatched' value.

And in adns__procdgram check the type before checking the (technically
in this case undefined) class.

In practice there is no bug in actual compiled code, because in both
call sites another test will DTRT.  I don't think contemporary
compilers spot and exploit this bug for "optimisation".

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoconsistency check: Tolerate done children on intdone
Ian Jackson [Thu, 8 Dec 2016 18:45:48 +0000 (18:45 +0000)]
consistency check: Tolerate done children on intdone

This can happen temporarily (for example, during globalsystemfailure
or during adns__query_fail's recursion through queries).

There is no problem unless it persists as we leave adns.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoControl flow: Document restrictions on globalsystemfailure
Ian Jackson [Thu, 8 Dec 2016 17:59:40 +0000 (17:59 +0000)]
Control flow: Document restrictions on globalsystemfailure

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agointernal.h: Use `unsigned' for nextid
Ian Jackson [Sat, 3 Dec 2016 16:54:44 +0000 (16:54 +0000)]
internal.h: Use `unsigned' for nextid

This is constantly incremented and needs to wrap.  In practice I don't
believe any compilers spot the UB.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agointernal.h: Add comment discouraging excessive MAXSERVERS
Ian Jackson [Sat, 3 Dec 2016 14:30:26 +0000 (14:30 +0000)]
internal.h: Add comment discouraging excessive MAXSERVERS

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoadns_processwriteable: assert that write did not write more than we asked
Ian Jackson [Thu, 1 Dec 2016 02:14:55 +0000 (02:14 +0000)]
adns_processwriteable: assert that write did not write more than we asked

This is better than proceeding to make tcpsend.used negative.

Should this ever happens, which it doesn't except under AFL, because
of a bug in hfuzzraw.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoadns: Correct a parsing error message very slightly
Ian Jackson [Thu, 1 Dec 2016 01:42:32 +0000 (01:42 +0000)]
adns: Correct a parsing error message very slightly

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoglobalsystemfailure: Do not tangle our lists
Ian Jackson [Thu, 1 Dec 2016 01:28:13 +0000 (01:28 +0000)]
globalsystemfailure: Do not tangle our lists

If a globalsystemfailure happens, we must remove each query from its
corresponding list, since adns__query_fail will try to remove it and
then put it on some other list.

Previously, any globalsystemfailure was likely to lead to an assertion
failure.  This doesn't seem to me to be a security problem.

Found by AFL.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosetup.c: Do not make wild pointer access if resolv.conf prefix length insane
Ian Jackson [Wed, 23 Nov 2016 17:08:26 +0000 (17:08 +0000)]
setup.c: Do not make wild pointer access if resolv.conf prefix length insane

(Found by AFL.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosetup.c: Do not fail assertion if `search' with no options in resolv.conf
Ian Jackson [Sat, 19 Nov 2016 19:41:06 +0000 (19:41 +0000)]
setup.c: Do not fail assertion if `search' with no options in resolv.conf

(Found by AFL.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agosrc/query.c: Correct assertion in free_interim
Ian Jackson [Sat, 19 Nov 2016 17:57:10 +0000 (17:57 +0000)]
src/query.c: Correct assertion in free_interim

!something is always >=0.  We meant to check that the free_interim
does not free more than was allocated.

Also do the assertion before the manipulation.  That reduces the
probability that a compiler will "prove" that the assertion is not
needed, or that it will fire too late.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agocommon.make.in: add -Wno-unused-value
Ian Jackson [Sat, 19 Nov 2016 18:14:09 +0000 (18:14 +0000)]
common.make.in: add -Wno-unused-value

Our GET_* macros return the value they've assigned, for convenience,
but this upsets new versions of gcc:

  warning: right-hand operand of comma expression has no effect [-Wunused-value]

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: Ignore apparent answers before first RR we found the first time
Ian Jackson [Sat, 10 Dec 2016 23:32:49 +0000 (23:32 +0000)]
SECURITY: Ignore apparent answers before first RR we found the first time

This way the second answer scan finds the same RRs at the first.
Otherwise, adns can be confused by interleaving answers for the CNAME
target, with the CNAME itself.

In that case the answer data structure (on the heap) can be overrun.

With this change, we prefer to look only at the answer RRs which come
after the CNAME, which is at least arguably correct.

Found by AFL 2.35b.  CVE-2017-9109.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: adnshost: Fix missing-final-newline handling on stdin read
Ian Jackson [Tue, 6 Dec 2016 12:51:44 +0000 (12:51 +0000)]
SECURITY: adnshost: Fix missing-final-newline handling on stdin read

It is wrong to increment used as well as setting r, since used is
incremented according to r, later.  Rather we should be doing what
read() would have done.

Without this fix, adnshost may read and process one byte beyond the
buffer, perhaps crashing or perhaps somehow leaking the value of that
byte.

Found by AFL 2.35b.  CVE-2017-9108.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: Do not overrun reading buffer if domain ends with backslash
Ian Jackson [Mon, 5 Dec 2016 22:47:34 +0000 (22:47 +0000)]
SECURITY: Do not overrun reading buffer if domain ends with backslash

If the query domain ended with \, and adns_qf_quoteok_query was
specified, qdparselabel would read additional bytes from the buffer
and try to treat them as the escape sequence.  It would depart the
input buffer and start processing many bytes of arbitrary heap data as
if it were the query domain.

Eventually it would run out of input or find some other kind of error,
and declare the query domain invalid.  But before then it might outrun
available memory and crash.

In principle this could be a denial of service attack.

Found by AFL 2.35b.  CVE-2017-9107.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: Make GETIL_B always have type `unsigned', not `int'
Ian Jackson [Sat, 3 Dec 2016 16:52:42 +0000 (16:52 +0000)]
SECURITY: Make GETIL_B always have type `unsigned', not `int'

Otherwise unwanted sign extension can easily occur when converting
from the implicit int to unsigned long, eg in GET_L.

Without this, ttls and the 32-bit SOA fields can be sign-extended,
exposing invalid values to the application.

Found by AFL 2.35b.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: Defend adns_rr_info (somewhat) from bogus *datap
Ian Jackson [Sat, 3 Dec 2016 14:51:54 +0000 (14:51 +0000)]
SECURITY: Defend adns_rr_info (somewhat) from bogus *datap

The general pattern for formatting integers is to sprintf into a
fixed-size buffer.  This is correct if the input is in the right
range; if it isn't, the buffer may be overrun (depending on the sizes
of the types on the current platform).

Of course the inputs ought to be right.  And there are pointers in
there too, so perhaps we could say that the caller ought to check
these things.  I think it's better to require the caller to make the
pointer structure right, but to have the code here be defensive about
(and tolerate with an erro but without crashing) out-of-range integer
values.

So: defend each of these integer conversion sites with a check for the
actual permitted range, and return adns_s_invaliddata if not.

The lack of this check causes the SOA sign extension bug to be a
serious security problem: the sign extended SOA value is out of range,
and will overrun the buffer when reconverted.

Found by AFL 2.35b.  CVE-2017-9106.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agocs_inthost*: Break out csp_intofinthost
Ian Jackson [Sat, 3 Dec 2016 14:51:18 +0000 (14:51 +0000)]
cs_inthost*: Break out csp_intofinthost

No functional change.

This removes some duplication, enabling the following security patch
to fix just the one copy.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: pa_soa: Do not sign extend SOA 32-bit integer fields on 64-bit
Ian Jackson [Sat, 3 Dec 2016 14:30:30 +0000 (14:30 +0000)]
SECURITY: pa_soa: Do not sign extend SOA 32-bit integer fields on 64-bit

The previous code used GET_W twice on two int variables, for no
explicable reason.  The top of these int variables was shifted left by
16, giving a 32-bit signed value.  The fields in adns_rr_soa are
unsigned long.  On a 64-bit machine, the 32-bit signed value is
implicitly sign extended.  This is entirely wrong.

Found by AFL 2.35b.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: adns: Do not corrupt pointer when nameserver speaks first
Ian Jackson [Thu, 1 Dec 2016 02:48:09 +0000 (02:48 +0000)]
SECURITY: adns: Do not corrupt pointer when nameserver speaks first

Wrong number of pointer dereferences.

This bug may well be exploitable as a remote code execution.

Found by AFL 2.35b.  CVE-2017-9105.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: Do not hang, eating CPU, if we encounter a compression pointer loop
Ian Jackson [Thu, 1 Dec 2016 01:42:56 +0000 (01:42 +0000)]
SECURITY: Do not hang, eating CPU, if we encounter a compression pointer loop

Found by AFL 2.35b.  CVE-2017-9104.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoSECURITY: pap_mailbox822: Properly check st from adns__findlabel_next
Ian Jackson [Wed, 23 Nov 2016 21:03:40 +0000 (21:03 +0000)]
SECURITY: pap_mailbox822: Properly check st from adns__findlabel_next

Without this, an uninitialised stack value can be used as the first
label length.  Depending on the circumstances, an attacker might be
able to trick adns into crashing the calling program, leaking aspects
of the contents of some of its memory, causing it to allocate lots of
memory, or perhaps overrunning a buffer.

This is only possible with applications which make non-raw queries for
SOA or RP records.

Found by AFL 2.35b.  CVE-2017-9103.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
7 years agochangelog: start 1.5.2~
Ian Jackson [Sat, 19 Nov 2016 13:53:12 +0000 (13:53 +0000)]
changelog: start 1.5.2~

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
7 years agochangelog, etc.: Finalise 1.5.1. adns-1.5.1
Ian Jackson [Fri, 12 Aug 2016 21:54:29 +0000 (22:54 +0100)]
changelog, etc.: Finalise 1.5.1.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
7 years agoUpdate copyright dates
Ian Jackson [Fri, 12 Aug 2016 21:52:38 +0000 (22:52 +0100)]
Update copyright dates

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
7 years agoNEWS: prepare for 1.5.1
Ian Jackson [Fri, 12 Aug 2016 21:49:29 +0000 (22:49 +0100)]
NEWS: prepare for 1.5.1

7 years agoRELEASE-CHECKLIST: Mention copyright
Ian Jackson [Fri, 12 Aug 2016 21:48:46 +0000 (22:48 +0100)]
RELEASE-CHECKLIST: Mention copyright

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
7 years agoProperly include harness.h in adnstest.c in regress/.
Ian Jackson [Fri, 12 Aug 2016 21:47:47 +0000 (22:47 +0100)]
Properly include harness.h in adnstest.c in regress/.

Suppresses a couple of compiler warnings (implicit declaration of
Texit, etc.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
7 years agoadnsresfilter: Fix addrtextbuf buffer size
Ian Jackson [Fri, 12 Aug 2016 21:32:23 +0000 (22:32 +0100)]
adnsresfilter: Fix addrtextbuf buffer size

We can write 18 bytes (including the trailing nul) to this.  This is
not actually a problem in real compiled code because: cbyte is
generally the next thing; cbytes's alignment means that there are a
further two bytes of padding; and we only write the next two bytes
(']' and a nul) in a situation where we are done with cbyte anyway.

But it should be fixed.

Reported-by: Ron Henderson
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoregress: Test MX whose addr has one tempfailing AF
Ian Jackson [Wed, 18 Feb 2015 23:42:21 +0000 (23:42 +0000)]
regress: Test MX whose addr has one tempfailing AF

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoregression tests: Properly handle adnshost et al exit status
Ian Jackson [Thu, 19 Feb 2015 00:55:53 +0000 (00:55 +0000)]
regression tests: Properly handle adnshost et al exit status

Only adnstest has an exit status which is compatible with the test
harness's ideas.  adnshost, in particular, uses `5' (skipped test) for
something else (worst failure was misconfig).

So we need to have two exit statuses, that of the program and that of
the test harness machinery.  To this end:

* Enhance the syscall emulation of exit to record the exit status as a
  normal syscall argument.  This has to be done slightly ad hoc
  because the hm_hsyscall macro cannot sanely generate nonreturning
  calls.  After this has been recorded, we do the shutdown activities
  as before and exit the test harness with status 0.

* The previous shutdown function (now the core of the exit emulation)
  is made available as Texit.

* adnstest (only) has a special test-harness-specific override to use
  the core, so a call to exit is not recorded and instead adnstest's
  exit status is that of the harness.

* Update all adnshost-based test cases to match.  This was done with
  this shell script (run once for each test, as needed):

    #!/bin/sh
    f=$1
    o=${f%.sys}.out
    rc=`sed -n '$s/^rc=//p' $o`
    sed -e '$s/^rc=.*/rc=0/' $o >$o.new
    mv $o.new $o
    echo " exit $rc" >>$f

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agochangelog: Change target suite for 1.5.1~~ to UPSTREAM
Ian Jackson [Sat, 21 Feb 2015 11:48:27 +0000 (11:48 +0000)]
changelog: Change target suite for 1.5.1~~ to UPSTREAM

9 years agosrc/types.c: Do not crash when one of several addr subqueries fails
Ian Jackson [Thu, 19 Feb 2015 01:05:33 +0000 (01:05 +0000)]
src/types.c: Do not crash when one of several addr subqueries fails

If a name passed to the addr lookup machinery (eg, passed to an
adns_r_addr query, or resulting from a dereferencing query like
adns_r_mx) has addresses for one address family (eg IPv4) but
temporary failure for another (eg IPv6) then adns might (would
usually) crash.

This is because icb_hostaddr would fail to reset the accumulated addrs
pointer to 0 after freeing it, and then set naddrs to -1.  The crash
would occur in makefinal, which would attempt to arrange to copy -1
elements into the unifed output buffer.

If the second AF gives a permanent error, the relevant part of the
answer would contain an invalid (freed) pointer, with a zero length.
The result during makefinal_query would be to allocate a zero length
`block' in the unified output result buffer and put the pointer to
that in the answer for the application, which is a violation of the
promised API.

This bug was introduced with IPv6 support (in 1.5.0, in commit
2ca5496dfc95).

A test case for this bug will be introduced shortly.

Reported-by: Chris Burton of 8086.net
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoregress: Add some tests with ~adns_if_noautosys
Ian Jackson [Wed, 28 Jan 2015 23:48:58 +0000 (23:48 +0000)]
regress: Add some tests with ~adns_if_noautosys

The test harness provides adns_if_noautosys by default (to make the
test .sys files more readable and less noisy, mostly).

But adns behaves rather differently with noautosys.  We should have
some more tests without it.  (The invocations of adnstest implied by
these new test cases produce obviously-wrong behaviour with an adns
which is lacking the TCP async connect API fix.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoregress: Remove update-extra-select conversion script
Ian Jackson [Sat, 21 Feb 2015 11:33:14 +0000 (11:33 +0000)]
regress: Remove update-extra-select conversion script

This script was a one-off.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoPortability: Fix assumption about read() and write() on connecting sockets
Ian Jackson [Wed, 28 Jan 2015 23:17:03 +0000 (23:17 +0000)]
Portability: Fix assumption about read() and write() on connecting sockets

Without adns_if_noautosys, adns would attempt read() on its TCP client
socket immediately after getting EINPROGRESS from connect(), and
assume that EAGAIN/EWOULDBLOCK means the socket is connected.

This is actually not correct on any platform that I'm aware of.
However, on Linux, write() on a socket which is being connected
returns EAGAIN, so everything seemed to work - adns would think that
the socket's window was full and wait for it to become writeable.  On
many other platforms, write() on such a socket returns ENOTCONN.

The result is that adns's TCP support may fail to work properly on
such platforms, especially if the nameserver is not localhost.  (A
connect to a suitable server on localhost often completes immediately,
which avoids exposing the bug.)  adns might fail to be able to do TCP
at all.

We detect the completion (successful or otherwise) of connect() by
selecting the fd (as contemplated by SuS).  This might expose us to
spurious fd writeability indications, if such things exist, but the
nonblocking connect API demands that they don't at least in this case.

We always do this select check, in adns_processwriteable.  In theory
this is sometimes unnecessary, because adns_processwriteable's caller
has probably just got a writeability indication from poll or select.
But adns should not assume that its caller will never feed it spurious
events, and there seems little point optimising away one syscall per
tcp connection (given that adns reuses the connection where possible.)

This behaviour naturally causes a lot of the regression tests to fail.
So in this commit we also update all the regression tests.  This has
been done in a programmatic way, by running
   perl -i ./update-extra-select case-*.sys

update-extra-select is supplied in this commit.  It is a (hopefully
easy to understand) script which adds a select just before every
applicable read.  The pretended select always reports that the fd is
useable, which is what would justify adns's subsequent behaviour.

(Most of the tests run with adns_if_noautosys - since that's the
default and has to be toggled off - and in those cases the socket has
in any case just been reported as writeable.)

Note that regress/update-extra-select is not idempotent.  Here, it has
been used exactly once.  (It is going to be deleted again in the next
commit.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoregress: Support NULL fdset arguments to select
Ian Jackson [Wed, 28 Jan 2015 23:49:19 +0000 (23:49 +0000)]
regress: Support NULL fdset arguments to select

We are going to want to pass these, and currently the test harness
will dereference the NULL.  So fix this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoFix for malicious optimisation of memcpy in test suite, which causes failure with...
Ian Jackson [Wed, 10 Dec 2014 23:16:37 +0000 (23:16 +0000)]
Fix for malicious optimisation of memcpy in test suite, which causes failure with gcc-4.1.9 -O3.  See Debian bug #772718.

9 years agoPortability fix for systems where socklen_t is bigger than int.
Ian Jackson [Sun, 2 Nov 2014 23:15:52 +0000 (23:15 +0000)]
Portability fix for systems where socklen_t is bigger than int.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoClarify licence in NEWS
Ian Jackson [Sun, 2 Nov 2014 19:22:46 +0000 (19:22 +0000)]
Clarify licence in NEWS

9 years agoStart 1.5.1~~
Ian Jackson [Sun, 2 Nov 2014 19:22:26 +0000 (19:22 +0000)]
Start 1.5.1~~

9 years agoRelease 1.5.0. No changes since 1.5.0~rc1. adns-1.5.0
Ian Jackson [Sun, 2 Nov 2014 15:00:56 +0000 (15:00 +0000)]
Release 1.5.0.  No changes since 1.5.0~rc1.

9 years agoMerge branch 'master' of chiark:public-git/adns
Ian Jackson [Sun, 26 Oct 2014 14:58:21 +0000 (14:58 +0000)]
Merge branch 'master' of chiark:public-git/adns

9 years agoRELEASE-CHECKLIST: Updates used during release of 1.5.0~rc1
Ian Jackson [Sun, 26 Oct 2014 14:57:58 +0000 (14:57 +0000)]
RELEASE-CHECKLIST: Updates used during release of 1.5.0~rc1

9 years agoUpdate versions for ongoing development
Ian Jackson [Sun, 26 Oct 2014 14:57:37 +0000 (14:57 +0000)]
Update versions for ongoing development

9 years agoFinalise 1.5.0~rc1 adns-1.5.0-rc1
Ian Jackson [Sun, 26 Oct 2014 13:25:14 +0000 (13:25 +0000)]
Finalise 1.5.0~rc1

9 years agoNEWS, changelog: Documentation for 1.5.0~rc1
Ian Jackson [Sun, 26 Oct 2014 13:21:16 +0000 (13:21 +0000)]
NEWS, changelog: Documentation for 1.5.0~rc1

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoregress/Makefile.in: Parallelise `make check'
Ian Jackson [Sun, 26 Oct 2014 11:58:09 +0000 (11:58 +0000)]
regress/Makefile.in: Parallelise `make check'

Use an individual target for each test.  This allows parallel make to
get its teeth into the problem.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoresolv.conf parsing: Test adns_af:dampstring
Ian Jackson [Sun, 26 Oct 2014 11:29:47 +0000 (11:29 +0000)]
resolv.conf parsing: Test adns_af:dampstring

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoresolv.conf parsing: Treat unknown adns_af: values correctly
Ian Jackson [Sun, 26 Oct 2014 11:28:56 +0000 (11:28 +0000)]
resolv.conf parsing: Treat unknown adns_af: values correctly

These shouldn't be fatal, and they should be affected by
ads->config_report_unknown.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoresolv.conf option parsing: Test adns_checkc
Ian Jackson [Sun, 26 Oct 2014 11:22:00 +0000 (11:22 +0000)]
resolv.conf option parsing: Test adns_checkc

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoresolv.conf parsing: Rename OPTION_IS etc. to WORD_IS
Ian Jackson [Sun, 26 Oct 2014 11:30:36 +0000 (11:30 +0000)]
resolv.conf parsing: Rename OPTION_IS etc. to WORD_IS

This now handles whatever is in `word', not necessarily the whole
option.  (We do this rename in a separate patch as it makes the
previous patch easier to review.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoresolv.conf option parsing: Fix word separation
Ian Jackson [Sun, 26 Oct 2014 11:06:09 +0000 (11:06 +0000)]
resolv.conf option parsing: Fix word separation

`nextword' does not nul-terminate the words it returns.  So the
strcmps in ccf_options are wrong.  Fix this as follows:

 * Abolish most uses of l in favour of a pointer variable endword.
 * Have OPTION_IS and OPTION_STARTS update word, and endword, so
   that it is convenient to use them for option values, etc.
 * Save the whole option in new variables opt and optend for
   reporting and to assist the `adns_af:' loop.
 * Use OPTION_IS, OPTION_STARTS and memchr, rather than strcmp,
   ad-hoc memcmp, and strcspn.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoRELEASE-CHECKLIST: Check that tarball is equal to git tree
Ian Jackson [Sat, 25 Oct 2014 22:01:50 +0000 (23:01 +0100)]
RELEASE-CHECKLIST: Check that tarball is equal to git tree

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoRELEASE-CHECKLIST: Non-real mode (the default, now)
Ian Jackson [Sat, 25 Oct 2014 21:04:49 +0000 (22:04 +0100)]
RELEASE-CHECKLIST: Non-real mode (the default, now)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoRELEASE-CHECKLIST: Require version argument
Ian Jackson [Sat, 25 Oct 2014 21:04:22 +0000 (22:04 +0100)]
RELEASE-CHECKLIST: Require version argument

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoConfig parsing: Provide a way to ignore unknown resolv.conf contents
Ian Jackson [Fri, 24 Oct 2014 21:12:33 +0000 (22:12 +0100)]
Config parsing: Provide a way to ignore unknown resolv.conf contents

You can now set the option `adns_ignoreunkcfg'.  This is relevant to
Debian #411263.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoConfig parsing: Ignore some BIND9-specific resolv.conf options
Ian Jackson [Fri, 24 Oct 2014 21:03:50 +0000 (22:03 +0100)]
Config parsing: Ignore some BIND9-specific resolv.conf options

Debian #411263.  I also read wheezy's resolv.conf(5).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoresolv.conf parser: Avoid duplicating lengths in option parser
Ian Jackson [Fri, 24 Oct 2014 20:49:44 +0000 (21:49 +0100)]
resolv.conf parser: Avoid duplicating lengths in option parser

Replace a lot of things like `l>=5 && memcmp(word,"debug",5)'
with use of some new macros.

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoAPI: Reject unknown flags
Ian Jackson [Fri, 24 Oct 2014 20:36:36 +0000 (21:36 +0100)]
API: Reject unknown flags

Check for unknown flags in adns_initflags, adns_queryflags, and
adns_rrtype.

This will allow us to extend the API in the future but still retain
backward-ABI-safety: new applications which pass a new flag but are
run against old adns will get an error (typically, ENOSYS).

In each case we reserve a few of the spare bits for `harmless'
extensions: flags which we decide, at the time of introduction, that
it is harmless for old implementations to ignore.

We simply provide explicit hex values for the flags.  This is easier
than listing all of the actually-defined flags, and probably no less
reliable.  Failing to add a new flag to the check as well as to the
enum will produce an obvious error (unless the `harmless' flag is used
- and those are at the top of the space to reduce that probability).

In the case of adns_rrtype, all of the external functions quickly pass
the type to adns__findtype, so we can do the check there.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoMake internal function vbuf__append_quoted1035 static
Ian Jackson [Fri, 24 Oct 2014 18:02:30 +0000 (19:02 +0100)]
Make internal function vbuf__append_quoted1035 static

This does not change the library ABI - the only callers are internal.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoRemove RCSids.
Ian Jackson [Fri, 24 Oct 2014 18:00:32 +0000 (19:00 +0100)]
Remove RCSids.

We are using git now and it doesn't do this kind of thing.  They are a
pain, anyway.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoBuild system: Add test case output and common.make to `make [dist]clean'.
Ian Jackson [Mon, 20 Oct 2014 16:03:42 +0000 (17:03 +0100)]
Build system: Add test case output and common.make to `make [dist]clean'.

(Cherry-picked from Debian's adns dgit/experimental branch.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoBuild system: Bodge regress/Makefile.in's .SECONDARY some more
Ian Jackson [Mon, 20 Oct 2014 15:34:52 +0000 (16:34 +0100)]
Build system: Bodge regress/Makefile.in's .SECONDARY some more

The declaration mentioning CLIENTS has an unfortunate side-effect: it
`mentions' the file adnshost_c.o, which is not part of the build and
is not buildable.

According to the rules in `(make)Implicit Rule Search' this causes
make to try to build adnshost_playback from adnshost_c.o (rule 5).
This is because files whose names are `mentioned' are taken to `ought
to exist'.

This causes adns to be unbuildable on the make from Debian sid
(4.0-8); it is not visible on earlier makes (eg 3.81-8.2) because they
don't appear to actually follow the documented algorithm.

Bodge this (further) by filtering adnshost out of the client list.  It
is currently the only client made out of multiple object files.

(Cherry-picked from Debian's adns dgit/experimental branch.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoregress: Use new combined hex syntax for adnstest types
Ian Jackson [Fri, 24 Oct 2014 17:53:02 +0000 (18:53 +0100)]
regress: Use new combined hex syntax for adnstest types

This makes the tests clearer to read.  No functional change.

Change was made with

  for f in regress/*.sys; do perl -i~ -p ../t.pl $f; done

where t.pl is this script

  if ($.==1) { $at=m{^(?:\./)?adnstest\b}; }
  if ($at && $.==2 && m/^:/) {
      m/^:(\S+)/ or die;
      $r=$'; #';
      $_=$1;
      s{\b(\d+)\b}{
  sprintf "0x%x|%d", ($1 & ~0xffff), ($1 & 0xffff)
      }ge;
      $_=":$_$r";
  }

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoadnstest: Support typenum being 0xXX|DDD
Ian Jackson [Fri, 24 Oct 2014 17:43:51 +0000 (18:43 +0100)]
adnstest: Support typenum being 0xXX|DDD

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoAPI: Provide adns_qf_cname_strict
Ian Jackson [Thu, 23 Oct 2014 19:31:48 +0000 (20:31 +0100)]
API: Provide adns_qf_cname_strict

In the medium term we want to make adns tolerate cname chains better.
One thing we want to do is to change the default to be
adns_qf_cname_loose.

So introduce a flag now that allows applications to explicitly request
strict.  For now this new flag has no effect.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoenums: Add `sizeforce' member value
Ian Jackson [Thu, 23 Oct 2014 19:02:59 +0000 (20:02 +0100)]
enums: Add `sizeforce' member value

The C standard helpfully permits enums with a small range of values to
be short.  This effect is not desirable in an API because it means that
adding new values (new flags, say) may cause ABI incompatibility.

Add some `sizeforce' members to relevant enums in the API.  In none of
the three cases do we expect this to actually cause an ABI break on
actual practical platforms, because the values we choose are within
the same power-of-two bitwidth.

Specifically:

                    max value in adns 1.4       new max value
  adns_initflags            0x0300                    0x7fff
  adns_queryflags       0x0ff00000                0x7fffffff
  adns_rrtype              0x20000                0x7fffffff
  adns_status                  499                 unchanged

The small max value of adns_initflags is unfortunate.  But we can't
change it without actually breaking the ABI on actual existing
platforms.  We can put off biting that bullet until we run out of
initflags - there are still three flags remaining.

This patch is not expected to have any practical effect with existing
platforms and compilers but it makes the code more correct and less
likely to be misoptimised by a future aggressive compiler.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years ago.gitignore: Ignore GPG signature
Ian Jackson [Mon, 20 Oct 2014 01:32:04 +0000 (02:32 +0100)]
.gitignore: Ignore GPG signature

9 years agoUpdate version numbers to be between releases
Ian Jackson [Mon, 20 Oct 2014 01:31:46 +0000 (02:31 +0100)]
Update version numbers to be between releases

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoRELEASE-CHECKLIST: Say to update versions after doing release
Ian Jackson [Mon, 20 Oct 2014 01:32:44 +0000 (02:32 +0100)]
RELEASE-CHECKLIST: Say to update versions after doing release

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoRELEASE-CHECKLIST: wip, as used for 1.5.0~rc0
Ian Jackson [Mon, 20 Oct 2014 01:30:36 +0000 (02:30 +0100)]
RELEASE-CHECKLIST: wip, as used for 1.5.0~rc0

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoREADME.html: Web page management changes adns-1.5.0-rc0
Ian Jackson [Mon, 20 Oct 2014 01:10:31 +0000 (02:10 +0100)]
README.html: Web page management changes

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoVersions: update to 1.5.0 RC0
Ian Jackson [Mon, 20 Oct 2014 00:37:40 +0000 (01:37 +0100)]
Versions: update to 1.5.0 RC0

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoNEWS: More updates
Ian Jackson [Mon, 20 Oct 2014 00:28:07 +0000 (01:28 +0100)]
NEWS: More updates

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoNEWS: Remove "pleased to announce" - should be in mail
Ian Jackson [Mon, 20 Oct 2014 00:26:31 +0000 (01:26 +0100)]
NEWS: Remove "pleased to announce" - should be in mail

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoREADME.html: Abolish dead link to BIND
Ian Jackson [Mon, 20 Oct 2014 00:25:44 +0000 (01:25 +0100)]
README.html: Abolish dead link to BIND

9 years agoREADME.html: mention signatures as possibly being on the web page
Ian Jackson [Mon, 20 Oct 2014 00:25:27 +0000 (01:25 +0100)]
README.html: mention signatures as possibly being on the web page

9 years agoBuild system: Provide `web-install' target
Ian Jackson [Mon, 20 Oct 2014 00:24:22 +0000 (01:24 +0100)]
Build system: Provide `web-install' target

This copies the various website files to WEBDIR.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoadns.h: Generalise some mentions of A RRs.
Ian Jackson [Mon, 20 Oct 2014 00:22:36 +0000 (01:22 +0100)]
adns.h: Generalise some mentions of A RRs.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoBuild system: Break out common.make[.in]
Ian Jackson [Mon, 20 Oct 2014 00:22:07 +0000 (01:22 +0100)]
Build system: Break out common.make[.in]

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoBuild system: Know how to build adnshost.txt
Ian Jackson [Mon, 20 Oct 2014 00:09:29 +0000 (01:09 +0100)]
Build system: Know how to build adnshost.txt

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agochangelog: Reorder slightly
Ian Jackson [Sun, 19 Oct 2014 23:57:17 +0000 (00:57 +0100)]
changelog: Reorder slightly

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agoBuild system: Do not include Makefile and src/config.h in distribution tarball
Ian Jackson [Sun, 19 Oct 2014 23:38:40 +0000 (00:38 +0100)]
Build system: Do not include Makefile and src/config.h in distribution tarball

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
9 years agochangelog: More updates
Ian Jackson [Sun, 19 Oct 2014 23:29:32 +0000 (00:29 +0100)]
changelog: More updates

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>