]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Minimum number of rdata fields should be checked parsing from wireformat too!
authorWillem Toorop <willem@NLnetLabs.nl>
Fri, 26 Aug 2011 14:53:40 +0000 (14:53 +0000)
committerWillem Toorop <willem@NLnetLabs.nl>
Fri, 26 Aug 2011 14:53:40 +0000 (14:53 +0000)
See bug #391.

error.c
ldns/error.h
wire2host.c

diff --git a/error.c b/error.c
index ff240dcc82a15c47118708dab59ca89f14f0e668..27277b8f390ef32f2ea13f309a2a434c79f0a645 100644 (file)
--- a/error.c
+++ b/error.c
@@ -88,6 +88,7 @@ ldns_lookup_table ldns_error_str[] = {
        { LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED, "RR not covered by the given NSEC RRs" },
        { LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED, "wildcard not covered by the given NSEC RRs" },
        { LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND, "original of NSEC3 hashed name could not be found" },
+       { LDNS_STATUS_WIRE_MISSING_RDATA_FIELDS, "More rdata fields were expected while parsing the wireformat data" },
        { 0, NULL }
 };
 
index e17846f38b3b1bc4c0dbbd4dc02144a86f8fccd4..4b2b62d7510a4f84fcc206f0259eb24a97c90da3 100644 (file)
@@ -98,7 +98,8 @@ enum ldns_enum_status {
        LDNS_STATUS_DNSSEC_EXISTENCE_DENIED,
        LDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVERED,
        LDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVERED,
-       LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND
+       LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND,
+       LDNS_STATUS_WIRE_MISSING_RDATA_FIELDS
 };
 typedef enum ldns_enum_status ldns_status;
 
index e87fcdf5df64725d891079752778411bbd6ddb82..5eb2acbd401ed10e2b9bae875248dd6665fdf6a2 100644 (file)
@@ -271,6 +271,9 @@ ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos)
                        cur_rdf = NULL;
                }
        }
+       if (rdf_index < ldns_rr_descriptor_minimum(descriptor)) {
+               return LDNS_STATUS_WIRE_MISSING_RDATA_FIELDS;
+       }
 
        return LDNS_STATUS_OK;
 }
@@ -316,10 +319,10 @@ ldns_wire2rr(ldns_rr **rr_p, const uint8_t *wire, size_t max,
                status = ldns_wire2rdf(rr, wire, max, pos);
 
                LDNS_STATUS_CHECK_GOTO(status, status_error);
-        ldns_rr_set_question(rr, false);
+               ldns_rr_set_question(rr, false);
        } else {
-        ldns_rr_set_question(rr, true);
-    }
+               ldns_rr_set_question(rr, true);
+       }
 
        *rr_p = rr;
        return LDNS_STATUS_OK;