Commit 4fa44d12 authored by Marek Vavruša's avatar Marek Vavruša

lib: fixed minor linter issues in lib

parent 112f9fef
......@@ -333,7 +333,7 @@ int kr_dnskeys_trusted(kr_rrset_validation_ctx_t *vctx, const knot_rrset_t *ta)
continue;
}
struct dseckey *key;
struct dseckey *key = NULL;
if (kr_dnssec_key_from_rdata(&key, keys->owner, key_data, knot_rdata_rdlen(krr)) != 0) {
continue;
}
......
......@@ -141,6 +141,9 @@ static int name_error_response_check_rr(int *flags, const knot_rrset_t *nsec,
while (ptr[0]) {
/* Remove leftmost label and replace it with '\1*'. */
ptr = (uint8_t *) knot_wire_next_label(ptr, NULL);
if (!ptr) {
return kr_error(EINVAL);
}
*(--ptr) = '*';
*(--ptr) = 1;
/* True if this wildcard provably doesn't exist. */
......
......@@ -210,6 +210,7 @@ static int sign_ctx_add_records(dnssec_sign_ctx_t *ctx, const knot_rrset_t *cove
for (int j = 0; j < trim_labels; ++j) {
assert(beginp[0]);
beginp = (uint8_t *) knot_wire_next_label(beginp, NULL);
assert(beginp != NULL);
}
*(--beginp) = '*';
*(--beginp) = 1;
......
......@@ -326,10 +326,14 @@ EXPORT void map_clear(map_t *map)
EXPORT int map_walk_prefixed(map_t *map, const char *prefix,
int (*callback)(const char *, void *, void *), void *baton)
{
if (!map) {
return 0;
}
const uint8_t *ubytes = (void *)prefix;
const size_t ulen = strlen(prefix);
uint8_t *p = map->root;
uint8_t *top = (uint8_t *)p;
uint8_t *top = p;
cb_data_t *data = NULL;
if (p == NULL) {
......
......@@ -400,6 +400,8 @@ int kr_nsrep_sort(struct kr_nsrep *ns, kr_nsrep_lru_t *cache)
}
}
/* At least two addresses must be in the address list */
assert(count > 0);
ns->score = scores[0];
ns->reputation = 0;
return kr_ok();
......
......@@ -1296,7 +1296,7 @@ static int zone_cut_check(struct kr_request *request, struct kr_query *qry, knot
} while (state == KR_STATE_CONSUME);
/* Update minimized QNAME if zone cut changed */
if (qry->zone_cut.name[0] != '\0' && !(qry->flags.NO_MINIMIZE)) {
if (qry->zone_cut.name && qry->zone_cut.name[0] != '\0' && !(qry->flags.NO_MINIMIZE)) {
if (kr_make_query(qry, packet) != 0) {
return KR_STATE_FAIL;
}
......
......@@ -108,6 +108,10 @@ void kr_log_verbose(const char *fmt, ...)
char* kr_strcatdup(unsigned n, ...)
{
if (n < 1) {
return NULL;
}
/* Calculate total length */
size_t total_len = 0;
va_list vl;
......@@ -402,7 +406,7 @@ int kr_straddr_subnet(void *dst, const char *addr)
if (subnet) {
*subnet = '\0';
subnet += 1;
bit_len = atoi(subnet);
bit_len = strtol(subnet, NULL, 10);
/* Check client subnet length */
const int max_len = (family == AF_INET6) ? 128 : 32;
if (bit_len < 0 || bit_len > max_len) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment