diff --git a/validator/autotrust.c b/validator/autotrust.c index 1220f7869..3266585f3 100644 --- a/validator/autotrust.c +++ b/validator/autotrust.c @@ -38,6 +38,7 @@ * * Contains autotrust implementation. The implementation was taken from * the autotrust daemon (BSD licensed), written by Matthijs Mekking. + * It was modified to fit into unbound. The state table process is the same. */ #include "config.h" #include "validator/autotrust.h" @@ -78,7 +79,7 @@ void autr_global_delete(struct autr_global_data* global) { if(!global) return; - /* elements deleted by parent, nothing to do */ + /* elements deleted by parent */ memset(global, 0, sizeof(*global)); free(global); } @@ -111,31 +112,10 @@ autr_get_num_anchors(struct val_anchors* anchors) static int position_in_string(char *str, const char* sub) { - int pos = -1, i = 0, j = 0; - char* walk; - const char* restore = sub; - while (*str != '\0') - { - walk = str; - j = 0; - while (*sub != '\0' && *walk == *sub) - { - sub++; - walk++; - j++; - } - - if (*sub == '\0' && j > 0) - pos = i; - - sub = restore; - j = 0; - i++; - str++; - } - if (pos < 0) - return pos; - return pos + (int)strlen(sub); + char* pos = strstr(str, sub); + if(pos) + return (int)(pos-str)+(int)strlen(sub); + return -1; } /** Debug routine to print pretty key information */ @@ -922,7 +902,8 @@ static void seen_trustanchor(struct autr_ta* ta, uint8_t seen) { ta->fetched = seen; - ta->pending_count++; + if(ta->pending_count < 250) /* no numerical overflow, please */ + ta->pending_count++; } /** set revoked value */ diff --git a/validator/autotrust.h b/validator/autotrust.h index 162016005..cb2c6e77b 100644 --- a/validator/autotrust.h +++ b/validator/autotrust.h @@ -67,7 +67,7 @@ struct autr_ta { struct autr_ta* next; /** the RR */ ldns_rr* rr; - /** last update of key state (not the pending count) */ + /** last update of key state (new pending count keeps date the same) */ time_t last_change; /** 5011 state */ autr_state_t s; @@ -94,7 +94,7 @@ struct autr_point_data { /** last queried DNSKEY set * Not all failures are captured in this entry. - * If the validator did not even start (e.g. timeout or servfail), + * If the validator did not even start (e.g. timeout or localservfail), * then the last_queried and query_failed values are not updated. */ time_t last_queried; @@ -186,6 +186,7 @@ void autr_point_delete(struct trust_anchor* tp); * allocated in a region. Has not been validated yet. * @return false if trust anchor was revoked completely. * Otherwise logs errors to log, does not change return value. + * On errors, likely the trust point has been unchanged. */ int autr_process_prime(struct module_env* env, struct val_env* ve, struct trust_anchor* tp, struct ub_packed_rrset_key* dnskey_rrset);