2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-03 08:05:21 +00:00

correct the DbC assertions in message.c

the comments for some calls in the dns_message API specified
requirements which were not actually enforced in the functions.

in most cases, this has now been corrected by adding the missing
REQUIREs. in one case, the comment was incorrect and has been
revised.
This commit is contained in:
Evan Hunt
2025-05-15 10:30:29 -07:00
parent b045726f8f
commit c437da59ee
2 changed files with 44 additions and 44 deletions

View File

@@ -528,9 +528,9 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
* 'preserve_order' setting.
*
* Requires:
*\li "msg" be valid.
*\li "msg" be a valid message with parsing intent.
*
*\li "buffer" be a wire format buffer.
*\li "source" be a wire format buffer.
*
* Ensures:
*\li The buffer's data format is correct.
@@ -560,7 +560,9 @@ dns_message_renderbegin(dns_message_t *msg, dns_compress_t *cctx,
*
* Requires:
*
*\li 'msg' be valid.
*\li 'msg' be a valid message with rendering intent.
*
*\li dns_message_renderbegin() has not previously been called.
*
*\li 'cctx' be valid.
*
@@ -610,8 +612,6 @@ dns_message_renderreserve(dns_message_t *msg, unsigned int space);
*
*\li 'msg' be valid.
*
*\li dns_message_renderbegin() was called.
*
* Returns:
*\li #ISC_R_SUCCESS -- all is well.
*\li #ISC_R_NOSPACE -- not enough free space in the buffer.
@@ -631,8 +631,6 @@ dns_message_renderrelease(dns_message_t *msg, unsigned int space);
*
*\li 'space' is less than or equal to the total amount of space reserved
* via prior calls to dns_message_renderreserve().
*
*\li dns_message_renderbegin() was called.
*/
isc_result_t
@@ -850,7 +848,7 @@ dns_message_removename(dns_message_t *msg, dns_name_t *name,
*
* Requires:
*
*\li 'msg' be valid, and be a renderable message.
*\li 'msg' be a valid message with rendering intent.
*
*\li 'name' be a valid absolute name.
*
@@ -1013,7 +1011,7 @@ dns_message_reply(dns_message_t *msg, bool want_question_section);
*
* Requires:
*
*\li 'msg' is a valid message with parsing intent, and contains a query.
*\li 'msg' is a valid message which contains a query.
*
* Ensures:
*
@@ -1061,7 +1059,7 @@ dns_message_setopt(dns_message_t *msg, dns_rdataset_t *opt);
*\li 'msg' is a valid message with rendering intent
* and no sections have been rendered.
*
*\li 'opt' is a valid OPT record or NULL.
*\li 'opt' is a valid OPT rdataset or NULL.
*
* Ensures:
*
@@ -1101,14 +1099,13 @@ isc_result_t
dns_message_settsigkey(dns_message_t *msg, dns_tsigkey_t *key);
/*%<
* Set the tsig key for 'msg'. This is only necessary for when rendering a
* query or parsing a response. The key (if non-NULL) is attached to, and
* will be detached when the message is destroyed.
* query or parsing a response. The key (if non-NULL) is attached to
* to the message, and will be detached when the message is destroyed.
*
* Requires:
*
*\li 'msg' is a valid message with rendering intent,
* dns_message_renderbegin() has been called, and no sections have been
* rendered.
*\li 'msg' is a valid message.
*
*\li 'key' is a valid tsig key or NULL.
*
* Returns:
@@ -1125,7 +1122,8 @@ dns_message_gettsigkey(dns_message_t *msg);
*
* Requires:
*
*\li 'msg' is a valid message
*\li 'msg' is a valid message, and dns_message_settsigkey() has been
* run previously.
*/
void
@@ -1137,10 +1135,11 @@ dns_message_setquerytsig(dns_message_t *msg, isc_buffer_t *querytsig);
*
* Requires:
*
*\li 'querytsig' is a valid buffer as returned by dns_message_getquerytsig()
*\li 'querytsig' is a valid buffer as returned by dns_message_getquerytsig(),
* or NULL
*
*\li 'msg' is a valid message
*\li 'msg' is a valid message on which dns_message_setquerytsig() has
* not previously been run.
*/
isc_result_t
@@ -1239,7 +1238,7 @@ dns_message_signer(dns_message_t *msg, dns_name_t *signer);
*
* Requires:
*
*\li msg is a valid parsed message.
*\li msg is a valid message with parsing intent.
*\li signer is a valid name
*
* Returns:

View File

@@ -2068,6 +2068,7 @@ dns_message_renderheader(dns_message_t *msg, isc_buffer_t *target) {
isc_region_t r;
REQUIRE(DNS_MESSAGE_VALID(msg));
REQUIRE(msg->buffer != NULL);
REQUIRE(target != NULL);
isc_buffer_availableregion(target, &r);
@@ -2394,7 +2395,7 @@ dns_message_addname(dns_message_t *msg, dns_name_t *name,
dns_section_t section) {
REQUIRE(msg != NULL);
REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER);
REQUIRE(name != NULL);
REQUIRE(dns_name_isabsolute(name));
REQUIRE(VALID_NAMED_SECTION(section));
ISC_LIST_APPEND(msg->sections[section], name, link);
@@ -2405,7 +2406,7 @@ dns_message_removename(dns_message_t *msg, dns_name_t *name,
dns_section_t section) {
REQUIRE(msg != NULL);
REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER);
REQUIRE(name != NULL);
REQUIRE(dns_name_isabsolute(name));
REQUIRE(VALID_NAMED_SECTION(section));
ISC_LIST_UNLINK(msg->sections[section], name, link);