]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
fixed bug in CERT RR type handling on bigendian systems
authorJelte Jansen <jeltejan@NLnetLabs.nl>
Tue, 17 Jan 2006 12:35:29 +0000 (12:35 +0000)
committerJelte Jansen <jeltejan@NLnetLabs.nl>
Tue, 17 Jan 2006 12:35:29 +0000 (12:35 +0000)
made rr reading a little bit more robust

error.c
ldns/error.h
rr.c
str2host.c
zone.c

diff --git a/error.c b/error.c
index 1216a9161382476013f6166f6ca089fb4aec1928..d488de8eb9afc951f41f2eda480ca55b2e90181a 100644 (file)
--- a/error.c
+++ b/error.c
@@ -56,6 +56,7 @@ ldns_lookup_table ldns_error_str[] = {
        { LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY, "authority section incomplete" },
        { LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL, "additional section incomplete" },
        { LDNS_STATUS_NO_DATA, "No data" },
+       { LDNS_STATUS_CERT_BAD_ALGORITHM, "Bad algorithm type for CERT record" },
        { 0, NULL }
 };
 
index 1b66baf745565859bdc76bd5f20150cb28190c54..38c25f7acab98de8c8b94bbbde4a4a3cf678630c 100644 (file)
@@ -60,7 +60,8 @@ enum ldns_enum_status
         LDNS_STATUS_WIRE_INCOMPLETE_ANSWER,
         LDNS_STATUS_WIRE_INCOMPLETE_AUTHORITY,
         LDNS_STATUS_WIRE_INCOMPLETE_ADDITIONAL,
-        LDNS_STATUS_NO_DATA
+        LDNS_STATUS_NO_DATA,
+        LDNS_STATUS_CERT_BAD_ALGORITHM
 };
 typedef enum ldns_enum_status ldns_status;
 
diff --git a/rr.c b/rr.c
index 6b0ebe11fcd0f3d37e5a0f285234c014434e0a9f..a29e7e4a5f6466fd0901ddd8c04503618b6f3fb6 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -390,8 +390,17 @@ ldns_rr_new_frm_str(const char *str, uint16_t default_ttl, ldns_rdf *origin, ldn
                                                                        rd);
                                                        break;
                                                }
-                                               ldns_rr_push_rdf(new, r);
-
+                                               if (r) {
+                                                       ldns_rr_push_rdf(new, r);
+                                               } else {
+                                                       LDNS_FREE(rd);
+                                                       LDNS_FREE(b64);
+                                                       ldns_buffer_free(rd_buf);
+                                                       ldns_buffer_free(rr_buf);
+                                                       LDNS_FREE(rdata);
+                                                       ldns_rr_free(new);
+                                                       return NULL;
+                                               }
                                                
                                        }
                                        if (quoted) {
index d9b3f8a7becbee23eb64e76f62c9beb94b2befa4..3c23745d7091821e989978daf510a662935c524e 100644 (file)
@@ -550,14 +550,15 @@ ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str)
 {
        ldns_lookup_table *lt;
        ldns_status st;
-
+       uint8_t id = 0;
        lt = ldns_lookup_by_name(ldns_cert_algorithms, str);
        st = LDNS_STATUS_OK;
 
        if (lt) {
+               id = lt->id;
                /* it was given as a integer */
                *rd = ldns_rdf_new_frm_data(
-                       LDNS_RDF_TYPE_INT8, sizeof(uint8_t), &lt->id);
+                       LDNS_RDF_TYPE_INT8, sizeof(uint8_t), &id);
                if (!*rd) {
                        st = LDNS_STATUS_ERR;
                }
@@ -565,6 +566,10 @@ ldns_str2rdf_cert_alg(ldns_rdf **rd, const char *str)
                /* try as-is (a number) */
                st = ldns_str2rdf_int8(rd, str);
        }
+       if (ldns_rdf2native_int8(*rd) == 0) {
+               fprintf(stderr, "Warning: Bad CERT algorithm type: %s ignoring RR\n", str);
+               st = LDNS_STATUS_CERT_BAD_ALGORITHM;
+       }
        return st;
 }
                
diff --git a/zone.c b/zone.c
index e03054c646dd8ddd6d798314d86ecd80ed3c0be5..01a2ddf06b89f912d18bbc082ac01fe45cc332af 100644 (file)
--- a/zone.c
+++ b/zone.c
@@ -195,6 +195,10 @@ ldns_zone_new_frm_fp_l(FILE *fp, ldns_rdf *origin, uint16_t ttl, ldns_rr_class c
                                ldns_zone_set_soa(newzone, rr);
                                continue;
                        }
+                       
+                       if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_CERT) {
+                               ldns_rr_print(stdout, rr);
+                       }
 
                        /* a normal RR - as sofar the DNS is normal */
                        last_rr = rr;