chiark / gitweb /
API: Reject unknown flags
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 24 Oct 2014 20:36:36 +0000 (21:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Oct 2014 11:42:43 +0000 (11:42 +0000)
commit039a0566b2e321bbfcb51f667d32b5d890ee6f61
treec4ebb2134c68e06692d3bedc5fd76c37db5ce141
parenta7f55cc47fd1a8c9d6e9e5eea2fc4184bfe7ad1c
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>
17 files changed:
regress/case-unknown-flags-harmless.err [new file with mode: 0644]
regress/case-unknown-flags-harmless.out [new file with mode: 0644]
regress/case-unknown-flags-harmless.sys [new file with mode: 0644]
regress/case-unknown-flags-init.err [new file with mode: 0644]
regress/case-unknown-flags-init.out [new file with mode: 0644]
regress/case-unknown-flags-init.sys [new file with mode: 0644]
regress/case-unknown-flags-query.err [new file with mode: 0644]
regress/case-unknown-flags-query.out [new file with mode: 0644]
regress/case-unknown-flags-query.sys [new file with mode: 0644]
regress/case-unknown-flags-type.err [new file with mode: 0644]
regress/case-unknown-flags-type.out [new file with mode: 0644]
regress/case-unknown-flags-type.sys [new file with mode: 0644]
src/addrfam.c
src/adns.h
src/query.c
src/setup.c
src/types.c