summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelte Jansen <jelte@NLnetLabs.nl>2008-12-19 14:56:46 +0100
committerJelte Jansen <jelte@NLnetLabs.nl>2008-12-19 14:56:46 +0100
commit02c56d61e7c9bb1ee915defa4f1d7f422d4c6316 (patch)
treea64ee5f48cc58941e5fce57855aefa92bf6f515e
parentb3ba1ed09bcd3c9ba983a6d9fdcad59adaa257a6 (diff)
downloadldns-release-1.4.x.tar.gz
added the NSEC type code fix from yesterday to 1.4.x branchrelease-1.4.x
-rw-r--r--dnssec.c11
-rw-r--r--str2host.c61
2 files changed, 13 insertions, 59 deletions
diff --git a/dnssec.c b/dnssec.c
index a5785f39..e0be3cee 100644
--- a/dnssec.c
+++ b/dnssec.c
@@ -607,14 +607,13 @@ ldns_dnssec_create_nsec_bitmap(ldns_rr_type rr_type_list[],
cur_window++;
cur_window_max = 0;
memset(cur_data, 0, 32);
- } else {
- cur_data[i%32] = bitmap[i];
- if (bitmap[i] > 0) {
- cur_window_max = i%32 + 1;
- }
+ }
+ cur_data[i%32] = bitmap[i];
+ if (bitmap[i] > 0) {
+ cur_window_max = i%32;
}
}
- if (cur_window_max > 0) {
+ if (cur_window_max > 0 || cur_data[0] != 0) {
/* this window has stuff, add it */
data = LDNS_XREALLOC(data,
uint8_t,
diff --git a/str2host.c b/str2host.c
index e034c217..49a37a7d 100644
--- a/str2host.c
+++ b/str2host.c
@@ -568,72 +568,27 @@ ldns_str2rdf_nsec(ldns_rdf **rd, const char *str)
{
const char *delimiters = "\n\t ";
char *token = LDNS_XMALLOC(char, LDNS_MAX_RDFLEN);
- uint8_t *bitmap = LDNS_XMALLOC(uint8_t, 1);
- uint16_t bm_len = 0;
ldns_buffer *str_buf;
ssize_t c;
uint16_t cur_type;
- uint8_t cur_data[32];
- uint8_t cur_window = 0;
- uint8_t cur_window_max = 0;
- uint16_t cur_data_size = 0;
- uint16_t i;
- uint8_t *data = NULL;
+ size_t type_count = 0;
+ ldns_rr_type type_list[1024];
str_buf = LDNS_MALLOC(ldns_buffer);
ldns_buffer_new_frm_data(str_buf, (char *)str, strlen(str));
- bitmap[0] = 0;
while ((c = ldns_bget_token(str_buf, token, delimiters, LDNS_MAX_RDFLEN)) != -1) {
cur_type = ldns_get_rr_type_by_name(token);
- if ((cur_type / 8) + 1 > bm_len) {
- bitmap = LDNS_XREALLOC(bitmap, uint8_t, (cur_type / 8) + 1);
- /* set to 0 */
- for (; bm_len <= cur_type / 8; bm_len++) {
- bitmap[bm_len] = 0;
- }
- }
- ldns_set_bit(bitmap + (int) cur_type / 8, (int) (7 - (cur_type % 8)), true);
- }
-
- memset(cur_data, 0, 32);
- for (i = 0; i < bm_len; i++) {
- if (i / 32 > cur_window) {
- /* check, copy, new */
- if (cur_window_max > 0) {
- /* this window has stuff, add it */
- data = LDNS_XREALLOC(data, uint8_t, cur_data_size + cur_window_max + 3);
- data[cur_data_size] = cur_window;
- data[cur_data_size + 1] = cur_window_max + 1;
- memcpy(data + cur_data_size + 2, cur_data, cur_window_max+1);
- cur_data_size += cur_window_max + 3;
- }
- cur_window++;
- cur_window_max = 0;
- memset(cur_data, 0, 32);
- } else {
- cur_data[i%32] = bitmap[i];
- if (bitmap[i] > 0) {
- cur_window_max = i%32;
- }
- }
- }
- if (cur_window_max > 0) {
- /* this window has stuff, add it */
- data = LDNS_XREALLOC(data, uint8_t, cur_data_size + cur_window_max + 3);
- data[cur_data_size] = cur_window;
- data[cur_data_size + 1] = cur_window_max + 1;
- memcpy(data + cur_data_size + 2, cur_data, cur_window_max+1);
- cur_data_size += cur_window_max + 3;
+ type_list[type_count] = cur_type;
+ type_count++;
}
+
+ *rd = ldns_dnssec_create_nsec_bitmap(type_list,
+ type_count,
+ LDNS_RR_TYPE_NSEC);
- *rd = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_NSEC, cur_data_size, data);
- if(data)
- LDNS_FREE(data);
if (token)
LDNS_FREE(token);
- if(bitmap)
- LDNS_FREE(bitmap);
ldns_buffer_free(str_buf);
return LDNS_STATUS_OK;
}