From: TCY16 Date: Thu, 28 Apr 2022 10:54:21 +0000 (+0200) Subject: fix final @TODOs with comments and better printing X-Git-Tag: 1.8.2-rc.1~3^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=514984785ce1abe9a5ada6564b453def443b06ff;p=thirdparty%2Fldns.git fix final @TODOs with comments and better printing --- diff --git a/host2str.c b/host2str.c index 82c024dc..26d62b87 100644 --- a/host2str.c +++ b/host2str.c @@ -2355,7 +2355,7 @@ ldns_edns_expire2buffer_str(ldns_buffer* output, uint8_t* data, size_t len) return ldns_buffer_status(output); } - // @TODO change this to be more accurate output + // TODO can this output be more accurate? ldns_edns_hex_data2buffer_str(output, data, len); return ldns_buffer_status(output); @@ -2551,7 +2551,7 @@ ldns_edns_ede2buffer_str(ldns_buffer* output, uint8_t* data, size_t len) break; default: ldns_buffer_printf(output, " %02x", data[0]); - ldns_buffer_printf(output, " %02x:", data[1]); + ldns_buffer_printf(output, " %02x", data[1]); break; } @@ -2609,15 +2609,13 @@ ldns_edns_server_tag2buffer_str(ldns_buffer* output, uint8_t* data, size_t len) return ldns_buffer_status(output); } -static ldns_status //@TODO change static? +ldns_status ldns_edns_option_list2buffer_str(ldns_buffer *output, ldns_edns_option_list* edns_list) { size_t count = ldns_edns_option_list_get_count(edns_list); size_t i, size; uint8_t* data; - // @TODO parse malformed? of in packet.c:ldns_pkt_edns_option_list() ? - for (i = 0; i < count; i++) { ldns_edns_option_code code; ldns_edns_option* edns = ldns_edns_option_list_get_option(edns_list, i); diff --git a/ldns/host2str.h b/ldns/host2str.h index f3cffd36..79f5561a 100644 --- a/ldns/host2str.h +++ b/ldns/host2str.h @@ -515,6 +515,17 @@ ldns_status ldns_rr2buffer_str_fmt(ldns_buffer *output, */ ldns_status ldns_pkt2buffer_str(ldns_buffer *output, const ldns_pkt *pkt); +/** + * Converts the list of EDNS options to presentation + * format (as char *) and appends it to the given buffer + * + * \param[in] output pointer to the buffer to append the data to + * \param[in] edns_list the list of EDNS options + * \return status + */ +ldns_status ldns_edns_option_list2buffer_str(ldns_buffer *output, + ldns_edns_option_list* edns_list); + /** * Converts the data in the DNS packet to presentation * format (as char *) and appends it to the given buffer diff --git a/packet.c b/packet.c index 0c16fd53..71d74cfe 100644 --- a/packet.c +++ b/packet.c @@ -778,7 +778,9 @@ ldns_pkt_edns_get_option_list(const ldns_pkt *packet) return packet->_edns_list; } - /* if the list doesn't exists, we create it by parsing the _edns_data */ + /* if the list doesn't exists, we create it by parsing the + * packet->_edns_data + */ assert(ldns_pkt_edns_data(packet)); max = ldns_rdf_size(ldns_pkt_edns_data(packet)); @@ -792,14 +794,15 @@ ldns_pkt_edns_get_option_list(const ldns_pkt *packet) while (pos < max) { ldns_edns_option* edns; uint8_t *data; - if (pos + 4 > max) { + if (pos + 4 > max) { /* make sure the header is */ ldns_edns_option_list_deep_free(edns_list); return NULL; } ldns_edns_option_code code = ldns_read_uint16(&wire[pos]); size_t size = ldns_read_uint16(&wire[pos+2]); pos += 4; - if (pos + size > max) { + + if (pos + size > max) { /* make sure the size fits the data */ ldns_edns_option_list_deep_free(edns_list); return NULL; }