From c463eb783e5ad999d400180c69b912c54fa07ee1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 10 Dec 2015 15:01:04 +0100 Subject: resolved: generalize DNS RR type validity checks Check the validity of RR types as we parse or receive data from IPC clients, and use the same code for all of them. --- src/resolve/dns-type.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/resolve/dns-type.c') diff --git a/src/resolve/dns-type.c b/src/resolve/dns-type.c index 8ce8a566f1..8281da3b7c 100644 --- a/src/resolve/dns-type.c +++ b/src/resolve/dns-type.c @@ -63,3 +63,25 @@ bool dns_type_is_pseudo(uint16_t type) { DNS_TYPE_TKEY ); } + +bool dns_type_is_valid_query(uint16_t type) { + + /* The types valid as questions in packets */ + + return !IN_SET(type, + 0, + DNS_TYPE_OPT, + DNS_TYPE_TSIG, + DNS_TYPE_TKEY); +} + +bool dns_type_is_valid_rr(uint16_t type) { + + /* The types valid as RR in packets (but not necessarily + * stored on servers). */ + + return !IN_SET(type, + DNS_TYPE_ANY, + DNS_TYPE_AXFR, + DNS_TYPE_IXFR); +} -- cgit v1.2.3-54-g00ecf