Skip to content

Commit

Permalink
Proper fix for issue #183 EDNS OPT can have no rdata
Browse files Browse the repository at this point in the history
  • Loading branch information
wtoorop committed Aug 15, 2022
1 parent b84b9d1 commit 228f0b2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions host2wire.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,16 @@ ldns_pkt2buffer_wire_compress(ldns_buffer *buffer, const ldns_pkt *packet, ldns_
, ldns_buffer_export(edns_buf));
ldns_buffer_free(edns_buf);
}
ldns_rr_push_rdf(edns_rr, edns_rdf ? edns_rdf : packet->_edns_data);
if (edns_rdf)
ldns_rr_push_rdf(edns_rr, edns_rdf);
else if (packet->_edns_data)
ldns_rr_push_rdf(edns_rr, packet->_edns_data);
(void)ldns_rr2buffer_wire_compress(buffer, edns_rr, LDNS_SECTION_ADDITIONAL, compression_data);
/* take the edns rdata back out of the rr before we free rr */
if (!edns_rdf)
/* if the rdata of the OPT came from packet->_edns_data
* we need to take it back out of the edns_rr before we free it
* so packet->_edns_data doesn't get freed
*/
if (!edns_rdf && packet->_edns_data)
(void)ldns_rr_pop_rdf (edns_rr);
ldns_rr_free(edns_rr);
}
Expand Down

0 comments on commit 228f0b2

Please sign in to comment.