mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +00:00
Add strict checks on typepair values in the developer's mode
When in developer's mode, make the DNS_TYPEPAIR_* macros be more strict on the contents of the 'base' and 'covers', so we can catch invalid use of the API.
This commit is contained in:
parent
76c027e949
commit
8837491697
@ -17,13 +17,38 @@
|
|||||||
|
|
||||||
#include <dns/types.h>
|
#include <dns/types.h>
|
||||||
|
|
||||||
#define DNS_TYPEPAIR_TYPE(type) ((dns_rdatatype_t)((type) & 0xFFFF))
|
#if DNS_TYPEPAIR_CHECK
|
||||||
#define DNS_TYPEPAIR_COVERS(type) ((dns_rdatatype_t)((type) >> 16))
|
#define DNS__TYPEPAIR_CHECK(base, covers) \
|
||||||
#define DNS_TYPEPAIR_VALUE(base, ext) \
|
INSIST((dns_rdatatype_issig(base) && covers != 0) || \
|
||||||
((dns_typepair_t)(((uint32_t)ext) << 16) | (((uint32_t)base) & 0xffff))
|
(base == 0 && covers != 0) || (base != 0 && covers == 0))
|
||||||
#define DNS_SIGTYPE(type) \
|
#else
|
||||||
((dns_typepair_t)(((uint32_t)type) << 16) | \
|
#define DNS__TYPEPAIR_CHECK(base, covers)
|
||||||
(((uint32_t)dns_rdatatype_rrsig) & 0xffff))
|
#endif
|
||||||
|
|
||||||
|
#define DNS_TYPEPAIR_TYPE(type) \
|
||||||
|
({ \
|
||||||
|
dns_rdatatype_t __base = (dns_rdatatype_t)((type) & 0xFFFF); \
|
||||||
|
dns_rdatatype_t __covers = (dns_rdatatype_t)((type) >> 16); \
|
||||||
|
DNS__TYPEPAIR_CHECK(__base, __covers); \
|
||||||
|
__base; \
|
||||||
|
})
|
||||||
|
#define DNS_TYPEPAIR_COVERS(type) \
|
||||||
|
({ \
|
||||||
|
dns_rdatatype_t __base = (dns_rdatatype_t)((type) & 0xFFFF); \
|
||||||
|
dns_rdatatype_t __covers = (dns_rdatatype_t)((type) >> 16); \
|
||||||
|
DNS__TYPEPAIR_CHECK(__base, __covers); \
|
||||||
|
__covers; \
|
||||||
|
})
|
||||||
|
#define DNS__TYPEPAIR_VALUE(base, covers) \
|
||||||
|
((dns_typepair_t)(((uint32_t)covers) << 16) | \
|
||||||
|
(((uint32_t)base) & 0xffff))
|
||||||
|
#define DNS_TYPEPAIR_VALUE(base, covers) \
|
||||||
|
({ \
|
||||||
|
DNS__TYPEPAIR_CHECK(base, covers); \
|
||||||
|
DNS__TYPEPAIR_VALUE(base, covers); \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define DNS_SIGTYPE(type) DNS__TYPEPAIR_VALUE(dns_rdatatype_rrsig, type)
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source);
|
dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source);
|
||||||
|
@ -307,6 +307,7 @@ if developer_mode
|
|||||||
config.set('ISC_MUTEX_ERROR_CHECK', 1)
|
config.set('ISC_MUTEX_ERROR_CHECK', 1)
|
||||||
config.set('ISC_SOCKET_DETAILS', 1)
|
config.set('ISC_SOCKET_DETAILS', 1)
|
||||||
config.set('ISC_STATS_CHECKUNDERFLOW', 1)
|
config.set('ISC_STATS_CHECKUNDERFLOW', 1)
|
||||||
|
config.set('DNS_TYPEPAIR_CHECK', 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
foreach fn : [
|
foreach fn : [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user