4504. [security] Allow the maximum number of records in a zone to

be specified.  This provides a control for issues
                        raised in CVE-2016-6170. [RT #42143]

(cherry picked from commit 5f8412a4cb)
This commit is contained in:
Mark Andrews
2016-11-03 10:46:37 +11:00
parent 34ffe07660
commit 51fe40fd59
34 changed files with 447 additions and 13 deletions

View File

@@ -194,6 +194,8 @@ typedef struct dns_dbmethods {
dns_clientinfo_t *clientinfo,
dns_rdataset_t *rdataset,
dns_rdataset_t *sigrdataset);
isc_result_t (*getsize)(dns_db_t *db, dns_dbversion_t *version,
isc_uint64_t *records, isc_uint64_t *bytes);
} dns_dbmethods_t;
typedef isc_result_t
@@ -1444,6 +1446,24 @@ dns_db_getnsec3parameters(dns_db_t *db, dns_dbversion_t *version,
* or this zone does not have NSEC3 records.
*/
isc_result_t
dns_db_getsize(dns_db_t *db, dns_dbversion_t *version, isc_uint64_t *records,
isc_uint64_t *bytes);
/*%<
* Get the number of records in the given version of the database as well
* as the number bytes used to store those records.
*
* Requires:
* \li 'db' is a valid zone database.
* \li 'version' is NULL or a valid version.
* \li 'records' is NULL or a pointer to return the record count in.
* \li 'bytes' is NULL or a pointer to return the byte count in.
*
* Returns:
* \li #ISC_R_SUCCESS
* \li #ISC_R_NOTIMPLEMENTED
*/
isc_result_t
dns_db_findnsec3node(dns_db_t *db, dns_name_t *name,
isc_boolean_t create, dns_dbnode_t **nodep);

View File

@@ -104,6 +104,7 @@ dns_rdataslab_tordataset(unsigned char *slab, unsigned int reservelen,
* Ensures:
*\li 'rdataset' is associated and points to a valid rdataest.
*/
unsigned int
dns_rdataslab_size(unsigned char *slab, unsigned int reservelen);
/*%<
@@ -116,6 +117,18 @@ dns_rdataslab_size(unsigned char *slab, unsigned int reservelen);
*\li The number of bytes in the slab, including the reservelen.
*/
unsigned int
dns_rdataslab_count(unsigned char *slab, unsigned int reservelen);
/*%<
* Return the number of records in the rdataslab
*
* Requires:
*\li 'slab' points to a slab.
*
* Returns:
*\li The number of records in the slab.
*/
isc_result_t
dns_rdataslab_merge(unsigned char *oslab, unsigned char *nslab,
unsigned int reservelen, isc_mem_t *mctx,

View File

@@ -157,8 +157,12 @@
#define DNS_R_BADCDS (ISC_RESULTCLASS_DNS + 111)
#define DNS_R_BADCDNSKEY (ISC_RESULTCLASS_DNS + 112)
#define DNS_R_OPTERR (ISC_RESULTCLASS_DNS + 113)
#define DNS_R_BADDNSTAP (ISC_RESULTCLASS_DNS + 114)
#define DNS_R_BADTSIG (ISC_RESULTCLASS_DNS + 115)
#define DNS_R_BADSIG0 (ISC_RESULTCLASS_DNS + 116)
#define DNS_R_TOOMANYRECORDS (ISC_RESULTCLASS_DNS + 117)
#define DNS_R_NRESULTS 114 /*%< Number of results */
#define DNS_R_NRESULTS 118 /*%< Number of results */
/*
* DNS wire format rcodes.

View File

@@ -289,6 +289,32 @@ dns_zone_getfile(dns_zone_t *zone);
*\li Pointer to null-terminated file name, or NULL.
*/
void
dns_zone_setmaxrecords(dns_zone_t *zone, isc_uint32_t records);
/*%<
* Sets the maximim number of records permitted in a zone.
* 0 implies unlimited.
*
* Requires:
*\li 'zone' to be valid initialised zone.
*
* Returns:
*\li void
*/
isc_uint32_t
dns_zone_getmaxrecords(dns_zone_t *zone);
/*%<
* Gets the maximim number of records permitted in a zone.
* 0 implies unlimited.
*
* Requires:
*\li 'zone' to be valid initialised zone.
*
* Returns:
*\li isc_uint32_t maxrecords.
*/
isc_result_t
dns_zone_load(dns_zone_t *zone);