*
* 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"
{
if(!global)
return;
- /* elements deleted by parent, nothing to do */
+ /* elements deleted by parent */
memset(global, 0, sizeof(*global));
free(global);
}
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 */
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 */
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;
/** 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;
* 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);