]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
fix final @TODOs with comments and better printing
authorTCY16 <tom@nlnetlabs.nl>
Thu, 28 Apr 2022 10:54:21 +0000 (12:54 +0200)
committerTCY16 <tom@nlnetlabs.nl>
Thu, 28 Apr 2022 10:54:21 +0000 (12:54 +0200)
host2str.c
ldns/host2str.h
packet.c

index 82c024dc3ec32a0353af5627278ebc335c5cdc27..26d62b87f9e6639d618ff62df072620c6a554d7c 100644 (file)
@@ -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);
index f3cffd3673f33319fab7b47fb3e50925b1088757..79f5561a9451082e8eb2a2014e13c07a58ccf438 100644 (file)
@@ -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
index 0c16fd537f177f871fdd7cfe1854bbfa946a1f04..71d74cfedf017b6c7ec50a6916fe8f98b06199d9 100644 (file)
--- 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;
                }