chiark / gitweb /
adns.git
3 years agoregress: Move case-*.in opening to shlib playback_prepare
Ian Jackson [Wed, 30 Nov 2016 23:34:38 +0000 (23:34 +0000)]
regress: Move case-*.in opening to shlib playback_prepare

make1test needs it too

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: implement poll
Ian Jackson [Wed, 30 Nov 2016 23:29:03 +0000 (23:29 +0000)]
regress: fuzzraw: implement poll

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Improve sync lost msg
Ian Jackson [Wed, 30 Nov 2016 23:27:02 +0000 (23:27 +0000)]
regress: fuzzraw: Improve sync lost msg

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Direct traceprint to stderr
Ian Jackson [Wed, 30 Nov 2016 23:21:07 +0000 (23:21 +0000)]
regress: fuzzraw: Direct traceprint to stderr

We open our own FILE* because the test program might fclose actual
stderr before returning from main.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Check traceprint in Q_vb
Ian Jackson [Wed, 30 Nov 2016 23:21:02 +0000 (23:21 +0000)]
regress: fuzzraw: Check traceprint in Q_vb

This may be called from Hexit, as well as our own Hfoos

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Add Tensuresetup into Hexit; remove it from Q_vb in hfuzzraw
Ian Jackson [Wed, 30 Nov 2016 23:17:02 +0000 (23:17 +0000)]
regress: Add Tensuresetup into Hexit; remove it from Q_vb in hfuzzraw

Everyone else's generated H* functions call Tensuresetup before they
call Q_vb.  So Hexit should too.

Q_vb in hfuzzraw no longer needs it then.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: playback: check poll sanity
Ian Jackson [Wed, 30 Nov 2016 23:13:36 +0000 (23:13 +0000)]
regress: playback: check poll sanity

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzz: change check1fuzz to send stderr to /dev/null
Ian Jackson [Wed, 30 Nov 2016 18:37:43 +0000 (18:37 +0000)]
regress: fuzz: change check1fuzz to send stderr to /dev/null

And also be less verbose when the test fails.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Rename traceprint functionality
Ian Jackson [Wed, 30 Nov 2016 18:28:38 +0000 (18:28 +0000)]
regress: fuzzraw: Rename traceprint functionality

Replace uses of stdout with uses of traceout, currently a #define.
Change some function names.

Only functional change is the change to the env var name.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: playback: Fold other Tensure calls into Tensuresetup
Ian Jackson [Wed, 30 Nov 2016 18:36:33 +0000 (18:36 +0000)]
regress: playback: Fold other Tensure calls into Tensuresetup

Rename Tensurereportfile and Tensurefuzzrawfile to be sure we didn't
miss any diredct call sites.

No significant functional change; we just do all of the idempotent
setup at each point.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Call Tensuresetup in Q_vb, just in case
Ian Jackson [Wed, 30 Nov 2016 18:34:37 +0000 (18:34 +0000)]
regress: fuzzraw: Call Tensuresetup in Q_vb, just in case

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Rename Tensurerecordfile to Tensuresetup
Ian Jackson [Wed, 30 Nov 2016 18:33:48 +0000 (18:33 +0000)]
regress: Rename Tensurerecordfile to Tensuresetup

This is much less confusing and reflects its real role better.  We
will deal with the remaining bits of Tensure<something> that aren't
Tensurerecordfile, in a moment.

 perl -i~ -pe 's/Tensurerecordfile/Tensuresetup/g' *.m4

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Move up Tensurerecordfile
Ian Jackson [Wed, 30 Nov 2016 18:25:32 +0000 (18:25 +0000)]
regress: fuzzraw: Move up Tensurerecordfile

Pure code motion

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: makefile and shell script fixes
Ian Jackson [Sun, 27 Nov 2016 22:24:34 +0000 (22:24 +0000)]
regress: fuzzraw: makefile and shell script fixes

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Allow any positive errno value
Ian Jackson [Sun, 27 Nov 2016 22:04:16 +0000 (22:04 +0000)]
regress: fuzzraw: Allow any positive errno value

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Use syscall_sync in Hclose
Ian Jackson [Sun, 27 Nov 2016 22:04:03 +0000 (22:04 +0000)]
regress: fuzzraw: Use syscall_sync in Hclose

This has to mirror the non-special close in hm_stdsyscall_close

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Break out syscall_sync
Ian Jackson [Sun, 27 Nov 2016 22:03:30 +0000 (22:03 +0000)]
regress: fuzzraw: Break out syscall_sync

No functional change

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: fixes and improvements to Paddr and Pbytes
Ian Jackson [Sun, 27 Nov 2016 21:55:28 +0000 (21:55 +0000)]
regress: fuzzraw: fixes and improvements to Paddr and Pbytes

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: work on fixing Paddr
Ian Jackson [Sun, 27 Nov 2016 21:46:24 +0000 (21:46 +0000)]
regress: fuzzraw: work on fixing Paddr

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Fix select Pfdset
Ian Jackson [Sun, 27 Nov 2016 21:32:01 +0000 (21:32 +0000)]
regress: fuzzraw: Fix select Pfdset

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Improve sync strings
Ian Jackson [Sun, 27 Nov 2016 20:32:09 +0000 (20:32 +0000)]
regress: fuzzraw: Improve sync strings

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Improve debug stdout from fuzzraw
Ian Jackson [Sun, 27 Nov 2016 20:31:56 +0000 (20:31 +0000)]
regress: Improve debug stdout from fuzzraw

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Introduce FUZZRAW_SYNC
Ian Jackson [Sun, 27 Nov 2016 19:48:04 +0000 (19:48 +0000)]
regress: Introduce FUZZRAW_SYNC

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Constify FR_write
Ian Jackson [Sun, 27 Nov 2016 19:48:26 +0000 (19:48 +0000)]
regress: Constify FR_write

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Fix fcntl
Ian Jackson [Sun, 27 Nov 2016 19:32:58 +0000 (19:32 +0000)]
regress: fuzzraw: Fix fcntl

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Fix gettimeofday
Ian Jackson [Sun, 27 Nov 2016 19:32:52 +0000 (19:32 +0000)]
regress: fuzzraw: Fix gettimeofday

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Fix P_succfail
Ian Jackson [Sun, 27 Nov 2016 19:32:39 +0000 (19:32 +0000)]
regress: fuzzraw: Fix P_succfail

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Fixes to fdsets
Ian Jackson [Sun, 27 Nov 2016 19:32:29 +0000 (19:32 +0000)]
regress: fuzzraw: Fixes to fdsets

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hfuzzraw: Introduce P_read_dump
Ian Jackson [Sun, 27 Nov 2016 17:55:37 +0000 (17:55 +0000)]
regress: hfuzzraw: Introduce P_read_dump

This really helps debugging.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hfuzzraw: Break out Tflushstdout
Ian Jackson [Sun, 27 Nov 2016 17:55:25 +0000 (17:55 +0000)]
regress: hfuzzraw: Break out Tflushstdout

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Handle select and poll return value specially
Ian Jackson [Sun, 27 Nov 2016 17:54:02 +0000 (17:54 +0000)]
regress: fuzzraw: Handle select and poll return value specially

Don't read or write it to the fuzzraw stream.  Instead, in hfuzzraw,
calculate it from the returned fd set (and check it's consistent with
the timeout).

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: *.m4: Add an hm_create_nothing to hrecord.c.m4
Ian Jackson [Sun, 27 Nov 2016 17:24:34 +0000 (17:24 +0000)]
regress: *.m4: Add an hm_create_nothing to hrecord.c.m4

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: *.m4: Provide for hm_rv_select and hm_rv_poll
Ian Jackson [Sun, 27 Nov 2016 17:21:20 +0000 (17:21 +0000)]
regress: *.m4: Provide for hm_rv_select and hm_rv_poll

They default to _any so there is no functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hmacros.i4: Provide hm_rv_* in hm_create_nothing
Ian Jackson [Sun, 27 Nov 2016 17:18:44 +0000 (17:18 +0000)]
regress: hmacros.i4: Provide hm_rv_* in hm_create_nothing

This is convenient, and it is going to become more so.  No functional
change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hfuzzraw: Fix close return value
Ian Jackson [Sun, 27 Nov 2016 17:30:18 +0000 (17:30 +0000)]
regress: hfuzzraw: Fix close return value

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hfuzzraw: Break out P_succfail()
Ian Jackson [Sun, 27 Nov 2016 17:29:20 +0000 (17:29 +0000)]
regress: hfuzzraw: Break out P_succfail()

Hclose needs it.  No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: playback fuzzraw generator: Get errno and result generation right
Ian Jackson [Sun, 27 Nov 2016 17:15:50 +0000 (17:15 +0000)]
regress: playback fuzzraw generator: Get errno and result generation right

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: playback fuzzraw generator: Fix a wrong pointer passed to fwrite
Ian Jackson [Sun, 27 Nov 2016 17:14:11 +0000 (17:14 +0000)]
regress: playback fuzzraw generator: Fix a wrong pointer passed to fwrite

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: Provide for ADNS_TEST_FUZZRAW_STDOUT_ENABLE
Ian Jackson [Sun, 27 Nov 2016 16:32:04 +0000 (16:32 +0000)]
regress: fuzzraw: Provide for ADNS_TEST_FUZZRAW_STDOUT_ENABLE

This generates sort-of-.sys-file output, which is useful for
debugging.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hfuzzraw: Fix a wrong pointer passed to fread
Ian Jackson [Sun, 27 Nov 2016 16:31:36 +0000 (16:31 +0000)]
regress: hfuzzraw: Fix a wrong pointer passed to fread

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hfuzzraw: Fix that Tensurerecordfile was not idempotent
Ian Jackson [Sun, 27 Nov 2016 16:30:57 +0000 (16:30 +0000)]
regress: hfuzzraw: Fix that Tensurerecordfile was not idempotent

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: make1fuzz: Make fuzzraw-* too
Ian Jackson [Sun, 27 Nov 2016 16:26:48 +0000 (16:26 +0000)]
regress: make1fuzz: Make fuzzraw-* too

And clean and .gitignore them.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hfuzz: Do not redirect stdout
Ian Jackson [Sun, 27 Nov 2016 16:25:45 +0000 (16:25 +0000)]
regress: hfuzz: Do not redirect stdout

(And anyway the dup2 was the wrong way round.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Reorganise r1test and make1fuzz some more
Ian Jackson [Sun, 27 Nov 2016 15:20:37 +0000 (15:20 +0000)]
regress: Reorganise r1test and make1fuzz some more

We are going to want make1fuzz to make the raw fuzzer input too.
That's done by the playback programs, so we need to call them.

This means it needs to make a copy of the syscall stream made by
playback_prepare.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: playback fuzzraw dump: Initial cut of raw file generator
Ian Jackson [Sun, 27 Nov 2016 14:25:46 +0000 (14:25 +0000)]
regress: playback fuzzraw dump: Initial cut of raw file generator

This has not been executed so it may well not work.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: playback fuzzraw dump: Move Tshutdown
Ian Jackson [Sun, 27 Nov 2016 14:25:08 +0000 (14:25 +0000)]
regress: playback fuzzraw dump: Move Tshutdown

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: fuzzraw: read new fds from stream
Ian Jackson [Sun, 27 Nov 2016 10:54:55 +0000 (10:54 +0000)]
regress: fuzzraw: read new fds from stream

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Make arrangements for fuzzraw of gettimeofday
Ian Jackson [Sun, 27 Nov 2016 10:47:33 +0000 (10:47 +0000)]
regress: Make arrangements for fuzzraw of gettimeofday

Provide a hook to call in Hgettimeofday which is a stub in all but
fuzzraw.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Make special arrangements for close()
Ian Jackson [Sun, 27 Nov 2016 10:09:49 +0000 (10:09 +0000)]
regress: Make special arrangements for close()

fuzzraw wants to track fds, so we can't just pass to through there.

All the other sites get a macro hm_stdsyscall_close to just get
the simple version.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hfuzzraw work in progress
Ian Jackson [Wed, 23 Nov 2016 22:50:26 +0000 (22:50 +0000)]
regress: hfuzzraw work in progress

It compiles. But:
 * close() needs to be handled specially since we are maintaining
   a synthetic fd table
 * it does not work at all yet and probably has other parts missing
 * want to (optionally) generate raw feed as part of playback
 * new fds need to get the chosen fd from the stream (and check
   it for sanity)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Fix a message about length return values
Ian Jackson [Wed, 23 Nov 2016 22:50:15 +0000 (22:50 +0000)]
regress: Fix a message about length return values

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Make fcntl extra arg be int, not long
Ian Jackson [Wed, 23 Nov 2016 22:49:47 +0000 (22:49 +0000)]
regress: Make fcntl extra arg be int, not long

Fixes test suite on platforms where long is not same size as int.
(Although it may work on some LE platforms anyway.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Provide Tnerrnos
Ian Jackson [Wed, 23 Nov 2016 22:46:42 +0000 (22:46 +0000)]
regress: Provide Tnerrnos

No users yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: hplayback: Do not tolerate hm_rv_any values out of range
Ian Jackson [Wed, 23 Nov 2016 17:32:09 +0000 (17:32 +0000)]
regress: hplayback: Do not tolerate hm_rv_any values out of range

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Do not crash if fd set fd out of range
Ian Jackson [Wed, 23 Nov 2016 17:26:09 +0000 (17:26 +0000)]
regress: Do not crash if fd set fd out of range

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Do not provide our own malloc in fuzz mode
Ian Jackson [Wed, 23 Nov 2016 16:44:44 +0000 (16:44 +0000)]
regress: Do not provide our own malloc in fuzz mode

We expect our fuzzer to have a stunt malloc.  So just provide stubs.

This involves moving our malloc wrapper to nonfuzz.c.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Rename Tallocshutdown to Tcommonshutdown
Ian Jackson [Wed, 23 Nov 2016 16:41:05 +0000 (16:41 +0000)]
regress: Rename Tallocshutdown to Tcommonshutdown

No functional change just yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: playback: Do not accept numeric errno values except 1..255
Ian Jackson [Wed, 23 Nov 2016 16:27:58 +0000 (16:27 +0000)]
regress: playback: Do not accept numeric errno values except 1..255

In particular do not accept zero, which the operating system won't
produce.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Provide fuzzcat.d
Ian Jackson [Sat, 19 Nov 2016 19:30:02 +0000 (19:30 +0000)]
regress: Provide fuzzcat.d

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Provide Makefile targets to generate fuzzer inputs
Ian Jackson [Sat, 19 Nov 2016 18:59:10 +0000 (18:59 +0000)]
regress: Provide Makefile targets to generate fuzzer inputs

These will be useful for seeding AFL and may be useful for other
purposes.  This also lets us check that at least with our existing
test cases, the corresponding fuzzer input files work.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This reverts commit 44843c19f7b3ebf59aa4cda4cef9be0f5d973126.

3 years agoregress: Fix skipped tests ($$ reference in Makefile)
Ian Jackson [Sat, 19 Nov 2016 18:59:22 +0000 (18:59 +0000)]
regress: Fix skipped tests ($$ reference in Makefile)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Introduce %_fuzz executables
Ian Jackson [Sat, 19 Nov 2016 18:38:25 +0000 (18:38 +0000)]
regress: Introduce %_fuzz executables

This takes a single input file containing command line arguments,
stdin, and syscall stream, and runs the playback on it.

This will be useful for fuzzers.

Currently nothing calls this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Move Texit into hnonfuzz
Ian Jackson [Sat, 19 Nov 2016 18:40:13 +0000 (18:40 +0000)]
regress: Move Texit into hnonfuzz

We are going to want to do this separately in the fuzz playback.  This
avoids difficulties with adnstest (which calls Texit rather than
Hexit) and programs which return from main(), both of which we want to
capture the exit status of in the fuzz playbacks.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Allow harness code to wrap main if it wants to
Ian Jackson [Sat, 19 Nov 2016 18:24:48 +0000 (18:24 +0000)]
regress: Allow harness code to wrap main if it wants to

The fuzzer is going to want to wrap main().  This is a bit awkward
because everyone defines it their own way (in ways which are obviously
equivalent but which trigger compiler warnings).  Our warnings mean we
have to make sure the comiler sees a declaration.

Luckily the only occurence of main() anywhere in one of the client
programs is (necessarily) the definition of main, which is always
defined to return int.  So we can arrange the expansion to produce
both declaration and definition of Hmain.

Then in hnonfuzz.c we need to declare Hmain.  (Which we can't declare
in the global header file.)  We hope that type errors in main are
unlikely.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Wrap up fopen() too
Ian Jackson [Sat, 19 Nov 2016 18:22:49 +0000 (18:22 +0000)]
regress: Wrap up fopen() too

The fuzzer is going to want to wrap fopen.  So add it to the special
syscall list, and implement it with the obvious wrapper in hnonfuzz.c.

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Introduce hnonfuzz.c and Ttestinputfd
Ian Jackson [Sat, 19 Nov 2016 18:19:10 +0000 (18:19 +0000)]
regress: Introduce hnonfuzz.c and Ttestinputfd

We are going to want to build a fuzzer target binary which will be
very like a playback binary, but provides a bit more wrapping.

For now we introduce hnonfuzz.o and link it into all the
currently-generated executables.

To make it not be an empty translation unit, combine this with:

Break out Ttestinputfd from hplayback.c.m4.

Neither of these changes produce any functional change.  (Ttestinputfd
ends up linked into *_record as well as *_playback but this is of no
consequence.)

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: shlib playback_prepare: Use test -e rather than test -f
Ian Jackson [Sat, 19 Nov 2016 18:11:09 +0000 (18:11 +0000)]
regress: shlib playback_prepare: Use test -e rather than test -f

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Break out some functions from r1test into a new file
Ian Jackson [Sat, 19 Nov 2016 18:02:56 +0000 (18:02 +0000)]
regress: Break out some functions from r1test into a new file

We are going to want to reuse some of this logic for parsing case-*.sys
files.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Break a line in the Makefile.in
Ian Jackson [Sun, 5 Mar 2017 21:26:02 +0000 (21:26 +0000)]
regress: Break a line in the Makefile.in

No functional change.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: Break out Tallocshutdown
Ian Jackson [Sat, 19 Nov 2016 17:37:56 +0000 (17:37 +0000)]
regress: Break out Tallocshutdown

No functional change

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: m1test: Use test -e rather than test -f
Ian Jackson [Sat, 19 Nov 2016 18:11:03 +0000 (18:11 +0000)]
regress: m1test: Use test -e rather than test -f

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
3 years agoregress: r1test: Use test -e rather than test -f
Ian Jackson [Sat, 19 Nov 2016 18:10:27 +0000 (18:10 +0000)]
regress: r1test: Use test -e rather than test -f

This avoids some silly error messages or other mistakes.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
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>