]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Always keep a copy of the message
authorMark Andrews <marka@isc.org>
Wed, 15 Jul 2020 06:07:51 +0000 (16:07 +1000)
committerMichał Kępień <michal@isc.org>
Wed, 5 Aug 2020 13:47:25 +0000 (15:47 +0200)
this allows it to be available even when dns_message_parse()
returns a error.

lib/dns/message.c

index dd9dd23a12c3478f3a9209652ade2d5b27f82947..97425c753b7c107ccbdc195f5f188f74efccb1b9 100644 (file)
@@ -1709,6 +1709,16 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
        msg->header_ok = 0;
        msg->question_ok = 0;
 
+       if ((options & DNS_MESSAGEPARSE_CLONEBUFFER) == 0) {
+               isc_buffer_usedregion(&origsource, &msg->saved);
+       } else {
+               msg->saved.length = isc_buffer_usedlength(&origsource);
+               msg->saved.base = isc_mem_get(msg->mctx, msg->saved.length);
+               memmove(msg->saved.base, isc_buffer_base(&origsource),
+                       msg->saved.length);
+               msg->free_saved = 1;
+       }
+
        isc_buffer_remainingregion(source, &r);
        if (r.length < DNS_MESSAGE_HEADERLEN) {
                return (ISC_R_UNEXPECTEDEND);
@@ -1793,15 +1803,6 @@ dns_message_parse(dns_message_t *msg, isc_buffer_t *source,
        }
 
 truncated:
-       if ((options & DNS_MESSAGEPARSE_CLONEBUFFER) == 0) {
-               isc_buffer_usedregion(&origsource, &msg->saved);
-       } else {
-               msg->saved.length = isc_buffer_usedlength(&origsource);
-               msg->saved.base = isc_mem_get(msg->mctx, msg->saved.length);
-               memmove(msg->saved.base, isc_buffer_base(&origsource),
-                       msg->saved.length);
-               msg->free_saved = 1;
-       }
 
        if (ret == ISC_R_UNEXPECTEDEND && ignore_tc) {
                return (DNS_R_RECOVERABLE);