From: Jelte Jansen Date: Tue, 17 Jan 2006 12:35:29 +0000 (+0000) Subject: fixed bug in CERT RR type handling on bigendian systems X-Git-Tag: release-1.1.0~418 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=992f2fc88400ecb44929446f442d9984996beefc;p=thirdparty%2Fldns.git fixed bug in CERT RR type handling on bigendian systems made rr reading a little bit more robust --- diff --git a/error.c b/error.c index 1216a916..d488de8e 100644 --- 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 } }; diff --git a/ldns/error.h b/ldns/error.h index 1b66baf7..38c25f7a 100644 --- a/ldns/error.h +++ b/ldns/error.h @@ -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 6b0ebe11..a29e7e4a 100644 --- 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) { diff --git a/str2host.c b/str2host.c index d9b3f8a7..3c23745d 100644 --- a/str2host.c +++ b/str2host.c @@ -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), <->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 e03054c6..01a2ddf0 100644 --- 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;