]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib: fixed minor linter issues in lib
authorMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 12 Jan 2018 06:07:30 +0000 (22:07 -0800)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 12 Jan 2018 06:12:22 +0000 (22:12 -0800)
lib/dnssec.c
lib/dnssec/nsec.c
lib/dnssec/signature.c
lib/generic/map.c
lib/nsrep.c
lib/resolve.c
lib/utils.c

index 98a89d63ada279a979695f9201d1c1dc7ea57c25..1d290733d8ea7b0e13bf3c3ca136f975a0a2b7de 100644 (file)
@@ -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;
                }
index ea64678ea2ee2378e8f3642b6975982e8a5d3d96..3335b3e8f0e8493163f427b64de0422f52beacae 100644 (file)
@@ -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. */
index 7c5ad16f93ae19c0f36ba9d3f47b2816dbba88ba..521412bc4f68f8ff73b01631a53a6e469da361ce 100644 (file)
@@ -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;
index 81a283dc5c900411875a3f9e8f622d37609ae7c8..da47b817c2dd11babd7108774c6ccb9a900b6265 100644 (file)
@@ -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) {
index e4452b57d8b2e4ca4167bd3482f541fed708978b..a2691007e221230218b524b55f01b16a07ff989f 100644 (file)
@@ -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();
index 1589a25834c29f192babd0b66874d93e35ba7f8e..7b9fb0e0ab1605c2c9aeeed5fdc211d395327181 100644 (file)
@@ -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;
                }
index 4cdff4297b0c448653576ee78ea00d2901fdf469..ac14767ce63aa29e58c02a7c687110a733b37c65 100644 (file)
@@ -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) {