From: Willem Toorop Date: Wed, 12 Dec 2012 13:44:30 +0000 (+0000) Subject: Rename aaaa_half to ilnp64 and more syntax checking on them. X-Git-Tag: release-1.6.17rc1~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60afe7894b37a061ba700855d12f0cf13e176503;p=thirdparty%2Fldns.git Rename aaaa_half to ilnp64 and more syntax checking on them. --- diff --git a/error.c b/error.c index 3fb3b5dc..e7a36c7e 100644 --- a/error.c +++ b/error.c @@ -125,7 +125,7 @@ ldns_lookup_table ldns_error_str[] = { { LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR, "The validation path " "did not end in a self-signed certificate" }, - { LDNS_STATUS_INVALID_AAAA_HALF, + { LDNS_STATUS_INVALID_ILNP64, "Conversion error, 4 colon seperated hex numbers expected" }, { 0, NULL } }; diff --git a/host2str.c b/host2str.c index 03a31bfe..bffae2fd 100644 --- a/host2str.c +++ b/host2str.c @@ -1050,7 +1050,7 @@ ldns_rdf2buffer_str_tsig(ldns_buffer *output, const ldns_rdf *rdf) } ldns_status -ldns_rdf2buffer_str_aaaa_half(ldns_buffer *output, const ldns_rdf *rdf) +ldns_rdf2buffer_str_ilnp64(ldns_buffer *output, const ldns_rdf *rdf) { ldns_buffer_printf(output,"%.4x:%.4x:%.4d:%.4x", ldns_read_uint16(ldns_rdf_data(rdf)), @@ -1158,8 +1158,8 @@ ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf) case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER: res = ldns_rdf2buffer_str_b32_ext(buffer, rdf); break; - case LDNS_RDF_TYPE_AAAA_HALF: - res = ldns_rdf2buffer_str_aaaa_half(buffer, rdf); + case LDNS_RDF_TYPE_ILNP64: + res = ldns_rdf2buffer_str_ilnp64(buffer, rdf); break; } } else { diff --git a/ldns/error.h b/ldns/error.h index bd18564c..ee31e3cd 100644 --- a/ldns/error.h +++ b/ldns/error.h @@ -119,7 +119,7 @@ enum ldns_enum_status { LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE, LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR, LDNS_STATUS_EXISTS_ERR, - LDNS_STATUS_INVALID_AAAA_HALF + LDNS_STATUS_INVALID_ILNP64 }; typedef enum ldns_enum_status ldns_status; diff --git a/ldns/host2str.h b/ldns/host2str.h index 792248e3..4b69ca62 100644 --- a/ldns/host2str.h +++ b/ldns/host2str.h @@ -519,13 +519,13 @@ ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf); ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf); /** - * Converts an LDNS_RDF_TYPE_AAAA_HALF rdata element to 4 hexadecimal numbers + * Converts an LDNS_RDF_TYPE_ILNP64 rdata element to 4 hexadecimal numbers * seperated by colons and adds it to the output buffer * \param[in] *rdf The rdata to convert * \param[in] *output The buffer to add the data to * \return LDNS_STATUS_OK on success, and error status on failure */ -ldns_status ldns_rdf2buffer_str_aaaa_half(ldns_buffer *output, +ldns_status ldns_rdf2buffer_str_ilnp64(ldns_buffer *output, const ldns_rdf *rdf); /** diff --git a/ldns/rdata.h b/ldns/rdata.h index fd36bb4e..7a91af47 100644 --- a/ldns/rdata.h +++ b/ldns/rdata.h @@ -107,7 +107,7 @@ enum ldns_enum_rdf_type /** nsec3 base32 string (with length byte on wire */ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, /** 4 shorts represented as 4 * 16 bit hex numbers seperated by colons */ - LDNS_RDF_TYPE_AAAA_HALF + LDNS_RDF_TYPE_ILNP64 }; typedef enum ldns_enum_rdf_type ldns_rdf_type; diff --git a/ldns/str2host.h b/ldns/str2host.h index f534d679..5ec2ccc9 100644 --- a/ldns/str2host.h +++ b/ldns/str2host.h @@ -250,7 +250,7 @@ ldns_status ldns_str2rdf_dname(ldns_rdf **rd, const char *str); * \param[in] str the string to be converted * \return ldns_status */ -ldns_status ldns_str2rdf_aaaa_half(ldns_rdf **rd, const char *str); +ldns_status ldns_str2rdf_ilnp64(ldns_rdf **rd, const char *str); #ifdef __cplusplus } diff --git a/rdata.c b/rdata.c index 1ae1372d..4c6e125e 100644 --- a/rdata.c +++ b/rdata.c @@ -336,8 +336,8 @@ ldns_rdf_new_frm_str(ldns_rdf_type type, const char *str) case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER: status = ldns_str2rdf_b32_ext(&rdf, str); break; - case LDNS_RDF_TYPE_AAAA_HALF: - status = ldns_str2rdf_aaaa_half(&rdf, str); + case LDNS_RDF_TYPE_ILNP64: + status = ldns_str2rdf_ilnp64(&rdf, str); break; case LDNS_RDF_TYPE_NONE: default: diff --git a/rr.c b/rr.c index 3b07b993..a3f3ce87 100644 --- a/rr.c +++ b/rr.c @@ -1960,7 +1960,7 @@ static const ldns_rdf_type type_tlsa_wireformat[] = { }; static const ldns_rdf_type type_nid_wireformat[] = { LDNS_RDF_TYPE_INT16, - LDNS_RDF_TYPE_AAAA_HALF + LDNS_RDF_TYPE_ILNP64 }; static const ldns_rdf_type type_l32_wireformat[] = { LDNS_RDF_TYPE_INT16, @@ -1968,7 +1968,7 @@ static const ldns_rdf_type type_l32_wireformat[] = { }; static const ldns_rdf_type type_l64_wireformat[] = { LDNS_RDF_TYPE_INT16, - LDNS_RDF_TYPE_AAAA_HALF + LDNS_RDF_TYPE_ILNP64 }; static const ldns_rdf_type type_lp_wireformat[] = { LDNS_RDF_TYPE_INT16, diff --git a/str2host.c b/str2host.c index c6154911..399974b1 100644 --- a/str2host.c +++ b/str2host.c @@ -1319,20 +1319,21 @@ ldns_str2rdf_ipseckey(ldns_rdf **rd, const char *str) } ldns_status -ldns_str2rdf_aaaa_half(ldns_rdf **rd, const char *str) +ldns_str2rdf_ilnp64(ldns_rdf **rd, const char *str) { unsigned int a, b, c, d; uint16_t shorts[4]; - if (sscanf(str, "%x:%x:%x:%x", &a, &b, &c, &d) == EOF) { - return LDNS_STATUS_INVALID_AAAA_HALF; + if (sscanf(str, "%4x:%4x:%4x:%4x", &a, &b, &c, &d) != 4 || + strpbrk(str, "+-") /* no signs */) { + return LDNS_STATUS_INVALID_ILNP64; } else { shorts[0] = htons(a); shorts[1] = htons(b); shorts[2] = htons(c); shorts[3] = htons(d); *rd = ldns_rdf_new_frm_data( - LDNS_RDF_TYPE_AAAA_HALF, 4 * sizeof(uint16_t), &shorts); + LDNS_RDF_TYPE_ILNP64, 4 * sizeof(uint16_t), &shorts); } return *rd ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR; } diff --git a/wire2host.c b/wire2host.c index 28dedede..dc9544d4 100644 --- a/wire2host.c +++ b/wire2host.c @@ -212,7 +212,7 @@ ldns_wire2rdf(ldns_rr *rr, const uint8_t *wire, size_t max, size_t *pos) case LDNS_RDF_TYPE_TSIGTIME: cur_rdf_length = LDNS_RDF_SIZE_6BYTES; break; - case LDNS_RDF_TYPE_AAAA_HALF: + case LDNS_RDF_TYPE_ILNP64: cur_rdf_length = LDNS_RDF_SIZE_8BYTES; break; case LDNS_RDF_TYPE_AAAA: