]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Lint test passes.
authorWouter Wijngaards <wouter@NLnetLabs.nl>
Fri, 11 Feb 2011 16:50:46 +0000 (16:50 +0000)
committerWouter Wijngaards <wouter@NLnetLabs.nl>
Fri, 11 Feb 2011 16:50:46 +0000 (16:50 +0000)
14 files changed:
dnssec.c
dnssec_sign.c
dnssec_verify.c
dnssec_zone.c
higher.c
host2str.c
host2wire.c
keys.c
net.c
rbtree.c
rr_functions.c
sha1.c
sha2.c
str2host.c

index 04d83b620b8211d06de464b430dbc996dc3239bb..329e67116b364cb4959ad49bb97c79bf6d8da81f 100644 (file)
--- a/dnssec.c
+++ b/dnssec.c
@@ -378,10 +378,12 @@ ldns_key_buf2dsa_raw(unsigned char* key, size_t len)
                BN_free(Y);
                return NULL;
        }
+#ifndef S_SPLINT_S
        dsa->p = P;
        dsa->q = Q;
        dsa->g = G;
        dsa->pub_key = Y;
+#endif /* splint */
 
        return dsa;
 }
@@ -444,8 +446,10 @@ ldns_key_buf2rsa_raw(unsigned char* key, size_t len)
                BN_free(modulus);
                return NULL;
        }
+#ifndef S_SPLINT_S
        rsa->n = modulus;
        rsa->e = exponent;
+#endif /* splint */
 
        return rsa;
 }
@@ -623,7 +627,7 @@ ldns_key_rr2ds(const ldns_rr *key, ldns_hash h)
                        return NULL;
                }
                tmp = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_HEX,
-                                           EVP_MD_size(md),
+                                           (size_t)EVP_MD_size(md),
                                            digest);
                ldns_rr_push_rdf(ds, tmp);
 #endif
@@ -916,7 +920,7 @@ ldns_create_nsec(ldns_rdf *cur_owner, ldns_rdf *next_owner, ldns_rr_list *rrs)
 
        ldns_rr *nsec = NULL;
        ldns_rr_type i_type_list[65536];
-       int type_count = 0;
+       size_t type_count = 0;
 
        nsec = ldns_rr_new();
        ldns_rr_set_type(nsec, LDNS_RR_TYPE_NSEC);
@@ -1134,7 +1138,7 @@ ldns_create_nsec3(ldns_rdf *cur_owner,
        ldns_status status;
 
     ldns_rr_type i_type_list[1024];
-       int type_count = 0;
+       size_t type_count = 0;
 
        hashed_owner = ldns_nsec3_hash_name(cur_owner,
                                                                 algorithm,
@@ -1679,8 +1683,8 @@ ldns_convert_ecdsa_rrsig_asn12rdf(const ldns_buffer *sig, const long sig_len)
         }
         BN_bn2bin(ecdsa_sig->r, data);
         BN_bn2bin(ecdsa_sig->s, data+BN_num_bytes(ecdsa_sig->r));
-       rdf = ldns_rdf_new(LDNS_RDF_TYPE_B64,
-                BN_num_bytes(ecdsa_sig->r) + BN_num_bytes(ecdsa_sig->s), data);
+       rdf = ldns_rdf_new(LDNS_RDF_TYPE_B64, (size_t)(
+               BN_num_bytes(ecdsa_sig->r) + BN_num_bytes(ecdsa_sig->s)), data);
         ECDSA_SIG_free(ecdsa_sig);
         return rdf;
 }
@@ -1691,7 +1695,7 @@ ldns_convert_ecdsa_rrsig_rdf2asn1(ldns_buffer *target_buffer,
 {
         ECDSA_SIG* sig;
        int raw_sig_len;
-        long bnsize = ldns_rdf_size(sig_rdf) / 2;
+        long bnsize = (long)ldns_rdf_size(sig_rdf) / 2;
         /* if too short, or not even length, do not bother */
         if(bnsize < 16 || (size_t)bnsize*2 != ldns_rdf_size(sig_rdf))
                 return LDNS_STATUS_ERR;
@@ -1710,9 +1714,10 @@ ldns_convert_ecdsa_rrsig_rdf2asn1(ldns_buffer *target_buffer,
 
        raw_sig_len = i2d_ECDSA_SIG(sig, NULL);
        if (ldns_buffer_reserve(target_buffer, (size_t) raw_sig_len)) {
-                unsigned char* pp = ldns_buffer_current(target_buffer);
+                unsigned char* pp = (unsigned char*)
+                       ldns_buffer_current(target_buffer);
                raw_sig_len = i2d_ECDSA_SIG(sig, &pp);
-                ldns_buffer_skip(target_buffer, (size_t) raw_sig_len);
+                ldns_buffer_skip(target_buffer, (ssize_t) raw_sig_len);
        }
         ECDSA_SIG_free(sig);
 
index 5d27761b94cd7ead307110f0a5df534eb9947af6..b21094465fe91fd32785b74cbfbd36182c355ed2 100644 (file)
@@ -120,7 +120,7 @@ ldns_sign_public_buffer(ldns_buffer *sign_buf, ldns_key *current_key)
 
        switch(ldns_key_algorithm(current_key)) {
        case LDNS_SIGN_DSA:
-       case LDNS_DSA_NSEC3:
+       case LDNS_SIGN_DSA_NSEC3:
                b64rdf = ldns_sign_public_evp(
                                   sign_buf,
                                   ldns_key_evp_key(current_key),
@@ -357,6 +357,7 @@ ldns_sign_public_dsa(ldns_buffer *to_sign, DSA *key)
 }
 
 #ifdef USE_ECDSA
+#ifndef S_SPLINT_S
 static int
 ldns_pkey_is_ecdsa(EVP_PKEY* pkey)
 {
@@ -380,6 +381,7 @@ ldns_pkey_is_ecdsa(EVP_PKEY* pkey)
         EC_KEY_free(ec);
         return 0;
 }
+#endif /* splint */
 #endif /* USE_ECDSA */
 
 ldns_rdf *
@@ -431,6 +433,7 @@ ldns_sign_public_evp(ldns_buffer *to_sign,
        }
 
        /* unfortunately, OpenSSL output is differenct from DNS DSA format */
+#ifndef S_SPLINT_S
        if (EVP_PKEY_type(key->type) == EVP_PKEY_DSA) {
                sigdata_rdf = ldns_convert_dsa_rrsig_asn12rdf(b64sig, siglen);
 #ifdef USE_ECDSA
@@ -443,6 +446,7 @@ ldns_sign_public_evp(ldns_buffer *to_sign,
                sigdata_rdf = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, siglen,
                                                                         ldns_buffer_begin(b64sig));
        }
+#endif /* splint */
        ldns_buffer_free(b64sig);
        EVP_MD_CTX_cleanup(&ctx);
        return sigdata_rdf;
@@ -640,7 +644,10 @@ ldns_dnssec_zone_create_nsecs(ldns_dnssec_zone *zone,
                                                  next_name,
                                                  LDNS_RR_TYPE_NSEC);
                ldns_rr_set_ttl(nsec_rr, nsec_ttl);
-               ldns_dnssec_name_add_rr(cur_name, nsec_rr);
+               if(ldns_dnssec_name_add_rr(cur_name, nsec_rr)!=LDNS_STATUS_OK){
+                       ldns_rr_free(nsec_rr);
+                       return LDNS_STATUS_ERR;
+               }
                ldns_rr_list_push_rr(new_rrs, nsec_rr);
                cur_node = next_node;
                if (cur_node) {
@@ -656,7 +663,10 @@ ldns_dnssec_zone_create_nsecs(ldns_dnssec_zone *zone,
                                                  next_name,
                                                  LDNS_RR_TYPE_NSEC);
                ldns_rr_set_ttl(nsec_rr, nsec_ttl);
-               ldns_dnssec_name_add_rr(cur_name, nsec_rr);
+               if(ldns_dnssec_name_add_rr(cur_name, nsec_rr)!=LDNS_STATUS_OK){
+                       ldns_rr_free(nsec_rr);
+                       return LDNS_STATUS_ERR;
+               }
                ldns_rr_list_push_rr(new_rrs, nsec_rr);
        } else {
                printf("error\n");
@@ -727,15 +737,18 @@ ldns_dnssec_zone_create_nsec3s(ldns_dnssec_zone *zone,
                        ldns_rdf_deep_free(ldns_rr_pop_rdf(nsec_rr));
                }
                ldns_rr_set_ttl(nsec_rr, nsec_ttl);
-               ldns_dnssec_name_add_rr(current_name, nsec_rr);
+               result = ldns_dnssec_name_add_rr(current_name, nsec_rr);
                ldns_rr_list_push_rr(new_rrs, nsec_rr);
                ldns_rr_list_push_rr(nsec3_list, nsec_rr);
                current_name_node = ldns_dnssec_name_node_next_nonglue(
                                   ldns_rbtree_next(current_name_node));
        }
+       if (result != LDNS_STATUS_OK) {
+               return result;
+       }
 
        ldns_rr_list_sort_nsec3(nsec3_list);
-       ldns_dnssec_chain_nsec3_list(nsec3_list);
+       result = ldns_dnssec_chain_nsec3_list(nsec3_list);
        if (result != LDNS_STATUS_OK) {
                return result;
        }
@@ -963,7 +976,7 @@ ldns_dnssec_zone_create_rrsigs_flg(ldns_dnssec_zone *zone,
                                        siglist = ldns_sign_public(rr_list, key_list);
                                        for (i = 0; i < ldns_rr_list_rr_count(siglist); i++) {
                                                if (cur_rrset->signatures) {
-                                                       ldns_dnssec_rrs_add_rr(cur_rrset->signatures,
+                                                       result = ldns_dnssec_rrs_add_rr(cur_rrset->signatures,
                                                                                           ldns_rr_list_rr(siglist,
                                                                                                                    i));
                                                } else {
@@ -998,7 +1011,7 @@ ldns_dnssec_zone_create_rrsigs_flg(ldns_dnssec_zone *zone,
 
                        for (i = 0; i < ldns_rr_list_rr_count(siglist); i++) {
                                if (cur_name->nsec_signatures) {
-                                       ldns_dnssec_rrs_add_rr(cur_name->nsec_signatures,
+                                       result = ldns_dnssec_rrs_add_rr(cur_name->nsec_signatures,
                                                                           ldns_rr_list_rr(siglist, i));
                                } else {
                                        cur_name->nsec_signatures = ldns_dnssec_rrs_new();
@@ -1044,7 +1057,10 @@ ldns_dnssec_zone_sign_flg(ldns_dnssec_zone *zone,
        }
 
        /* zone is already sorted */
-       ldns_dnssec_zone_mark_glue(zone);
+       result = ldns_dnssec_zone_mark_glue(zone);
+       if (result != LDNS_STATUS_OK) {
+               return result;
+       }
 
        /* check whether we need to add nsecs */
        if (zone->names && !((ldns_dnssec_name *)zone->names->root->data)->nsec) {
@@ -1097,14 +1113,20 @@ ldns_dnssec_zone_sign_nsec3_flg(ldns_dnssec_zone *zone,
        ldns_status result = LDNS_STATUS_OK;
 
        /* zone is already sorted */
-       ldns_dnssec_zone_mark_glue(zone);
+       result = ldns_dnssec_zone_mark_glue(zone);
+       if (result != LDNS_STATUS_OK) {
+               return result;
+       }
 
        /* TODO if there are already nsec3s presents and their
         * parameters are the same as these, we don't have to recreate
         */
        if (zone->names) {
                /* add empty nonterminals */
-               ldns_dnssec_zone_add_empty_nonterminals(zone);
+               result = ldns_dnssec_zone_add_empty_nonterminals(zone);
+               if (result != LDNS_STATUS_OK) {
+                       return result;
+               }
 
                nsec3 = ((ldns_dnssec_name *)zone->names->root->data)->nsec;
                if (nsec3 && ldns_rr_get_type(nsec3) == LDNS_RR_TYPE_NSEC3) {
@@ -1127,7 +1149,10 @@ ldns_dnssec_zone_sign_nsec3_flg(ldns_dnssec_zone *zone,
                                /* always set bit 7 of the flags to zero, according to
                                 * rfc5155 section 11 */
                                ldns_set_bit(ldns_rdf_data(ldns_rr_rdf(nsec3params, 1)), 7, 0);
-                               ldns_dnssec_zone_add_rr(zone, nsec3params);
+                               result = ldns_dnssec_zone_add_rr(zone, nsec3params);
+                               if (result != LDNS_STATUS_OK) {
+                                       return result;
+                               }
                                ldns_rr_list_push_rr(new_rrs, nsec3params);
                        }
                        result = ldns_dnssec_zone_create_nsec3s(zone,
index 775f7de00e0da28627a71211bec13828c41c89e8..352e44066b15eb40feecb9e87f21498a297e181d 100644 (file)
@@ -1536,7 +1536,7 @@ ldns_gost2pkey_raw(unsigned char* key, size_t keylen)
        memmove(encoded+37, key, 64);
        pp = (unsigned char*)&encoded[0];
 
-       return d2i_PUBKEY(NULL, &pp, sizeof(encoded));
+       return d2i_PUBKEY(NULL, &pp, (int)sizeof(encoded));
 }
 
 static ldns_status
@@ -1585,7 +1585,7 @@ ldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo)
         * of openssl) for uncompressed data */
        buf[0] = POINT_CONVERSION_UNCOMPRESSED;
        memmove(buf+1, key, keylen);
-        if(!o2i_ECPublicKey(&ec, &pp, keylen+1)) {
+        if(!o2i_ECPublicKey(&ec, &pp, (int)keylen+1)) {
                 EC_KEY_free(ec);
                 return NULL;
         }
index 5bf1488f976d40f7d3e8e74e17ba470776b4c21e..e2a5fce6edd321f294fb8dec42a89d8789fdadbd 100644 (file)
@@ -320,7 +320,10 @@ ldns_dnssec_name_new_frm_rr(ldns_rr *rr)
        ldns_dnssec_name *new_name = ldns_dnssec_name_new();
 
        new_name->name = ldns_rr_owner(rr);
-       ldns_dnssec_name_add_rr(new_name, rr);
+       if(ldns_dnssec_name_add_rr(new_name, rr) != LDNS_STATUS_OK) {
+               ldns_dnssec_name_free(new_name);
+               return NULL;
+       }
 
        return new_name;
 }
@@ -458,7 +461,7 @@ ldns_dnssec_name_add_rr(ldns_dnssec_name *name,
        } else if (typecovered == LDNS_RR_TYPE_NSEC ||
                         typecovered == LDNS_RR_TYPE_NSEC3) {
                if (name->nsec_signatures) {
-                       ldns_dnssec_rrs_add_rr(name->nsec_signatures, rr);
+                       result = ldns_dnssec_rrs_add_rr(name->nsec_signatures, rr);
                } else {
                        name->nsec_signatures = ldns_dnssec_rrs_new();
                        name->nsec_signatures->rr = rr;
@@ -516,15 +519,6 @@ ldns_dnssec_zone_find_rrset(ldns_dnssec_zone *zone,
        }
 }
 
-static inline void
-print_indent(FILE *out, int c)
-{
-       int i;
-       for (i=0; i<c; i++) {
-               fprintf(out, "    ");
-       }
-}
-
 void
 ldns_dnssec_name_print_soa(FILE *out, ldns_dnssec_name *name, bool show_soa)
 {
@@ -686,10 +680,10 @@ ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, ldns_rr *rr)
                 }
                cur_node->key = ldns_rr_owner(rr);
                cur_node->data = cur_name;
-               ldns_rbtree_insert(zone->names, cur_node);
+               (void)ldns_rbtree_insert(zone->names, cur_node);
        } else {
                cur_name = (ldns_dnssec_name *) cur_node->data;
-               ldns_dnssec_name_add_rr(cur_name, rr);
+               result = ldns_dnssec_name_add_rr(cur_name, rr);
        }
 
        if (result != LDNS_STATUS_OK) {
@@ -793,9 +787,9 @@ ldns_dnssec_zone_add_empty_nonterminals(ldns_dnssec_zone *zone)
                 * label in the current name (counting from the end)
                 */
                for (i = 1; i < next_label_count - soa_label_count; i++) {
-                       lpos = cur_label_count - next_label_count + i;
+                       lpos = (int)cur_label_count - (int)next_label_count + (int)i;
                        if (lpos >= 0) {
-                               l1 = ldns_dname_label(cur_name, lpos);
+                               l1 = ldns_dname_label(cur_name, (uint8_t)lpos);
                        } else {
                                l1 = NULL;
                        }
@@ -823,7 +817,7 @@ ldns_dnssec_zone_add_empty_nonterminals(ldns_dnssec_zone *zone)
                                }
                                new_node->key = new_name->name;
                                new_node->data = new_name;
-                               ldns_rbtree_insert(zone->names, new_node);
+                               (void)ldns_rbtree_insert(zone->names, new_node);
                        }
                        ldns_rdf_deep_free(l1);
                        ldns_rdf_deep_free(l2);
index 48e94defe431736e27ec347388995bb97cb3db73..1563e821b6df35d2547ad20a652399c19fe6336a 100644 (file)
--- a/higher.c
+++ b/higher.c
@@ -212,7 +212,7 @@ ldns_get_rr_list_hosts_frm_fp_l(FILE *fp, int *line_nr)
                                                break;
                                        }
                                }
-                               strlcpy(addr, word, LDNS_MAX_LINELEN+1);
+                               (void)strlcpy(addr, word, LDNS_MAX_LINELEN+1);
                        } else {
                                /* la al la la */
                                if (ip6) {
index e92937f23b9c6188e76f08370557792a5d8d7c6a..37e01bfe6871fc6b817dda93e2fbc1c7474d2dd2 100644 (file)
@@ -823,11 +823,11 @@ ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)
        uint8_t prefix;
        bool negation;
        uint8_t adf_length;
-       unsigned short i;
-       unsigned int pos = 0;
+       size_t i;
+       size_t pos = 0;
 
        while (pos < (unsigned int) ldns_rdf_size(rdf)) {
-                if(pos + 3 >= ldns_rdf_size(rdf))
+                if(pos + 3 >= (unsigned)ldns_rdf_size(rdf))
                         return LDNS_STATUS_SYNTAX_RDATA_ERR;
                address_family = ldns_read_uint16(&data[pos]);
                prefix = data[pos + 2];
@@ -1431,7 +1431,7 @@ ldns_gost_key2buffer_str(ldns_buffer *output, EVP_PKEY *p)
        ldns_buffer_printf(output, "GostAsn1: ");
 
        ret = i2d_PrivateKey(p, &pp);
-       b64_bignum = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, ret, pp);
+       b64_bignum = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_B64, (size_t)ret, pp);
        status = ldns_rdf2buffer_str(output, b64_bignum);
 
        ldns_rdf_deep_free(b64_bignum);
@@ -1446,11 +1446,13 @@ ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
 {
        ldns_status status = LDNS_STATUS_OK;
        unsigned char  *bignum;
+#ifndef S_SPLINT_S
+       uint16_t i;
+#endif
 
 #ifdef HAVE_SSL
        /* not used when ssl is not defined */
        ldns_rdf *b64_bignum = NULL;
-       uint16_t i;
 
        RSA *rsa;
        DSA *dsa;
@@ -1520,6 +1522,7 @@ ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
                                /* print to buf, convert to bin, convert to b64,
                                 * print to buf */
                                ldns_buffer_printf(output, "Modulus: ");
+#ifndef S_SPLINT_S
                                i = (uint16_t)BN_bn2bin(rsa->n, bignum);
                                if (i > LDNS_MAX_KEYLEN) {
                                        goto error;
@@ -1637,6 +1640,7 @@ ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
                                } else {
                                        ldns_buffer_printf(output, "(Not available)\n");
                                }
+#endif /* splint */
 
                                RSA_free(rsa);
                                break;
@@ -1654,6 +1658,7 @@ ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
                                /* print to buf, convert to bin, convert to b64,
                                 * print to buf */
                                ldns_buffer_printf(output, "Prime(p): ");
+#ifndef S_SPLINT_S
                                if (dsa->p) {
                                        i = (uint16_t)BN_bn2bin(dsa->p, bignum);
                                        if (i > LDNS_MAX_KEYLEN) {
@@ -1732,13 +1737,21 @@ ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
                                } else {
                                        printf("(Not available)\n");
                                }
+#endif /* splint */
                                break;
                        case LDNS_SIGN_ECC_GOST:
                                /* no format defined, use blob */
 #if defined(HAVE_SSL) && defined(USE_GOST)
                                ldns_buffer_printf(output, "Private-key-format: v1.2\n");
                                ldns_buffer_printf(output, "Algorithm: %d (ECC-GOST)\n", LDNS_SIGN_ECC_GOST);
-                               status = ldns_gost_key2buffer_str(output, k->_key.key);
+                               status = ldns_gost_key2buffer_str(output, 
+#ifndef S_SPLINT_S
+                                       k->_key.key
+#else
+                                       NULL
+#endif
+                               );
+
 #endif
                                break;
 #ifdef USE_ECDSA
@@ -1746,7 +1759,8 @@ ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
                        case LDNS_SIGN_ECDSAP384SHA384:
                                 ldns_buffer_printf(output, "Private-key-format: v1.2\n");
                                ldns_buffer_printf(output, "Algorithm: %d (", ldns_key_algorithm(k));
-                                ldns_algorithm2buffer_str(output, ldns_key_algorithm(k));
+                                status=ldns_algorithm2buffer_str(output, (ldns_algorithm)ldns_key_algorithm(k));
+#ifndef S_SPLINT_S
                                ldns_buffer_printf(output, ")\n");
                                 if(k->_key.key) {
                                         EC_KEY* ec = EVP_PKEY_get1_EC_KEY(k->_key.key);
@@ -1766,6 +1780,7 @@ ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
                                          * its still assigned to the PKEY */
                                         EC_KEY_free(ec);
                                 }
+#endif /* splint */
                                 break;
 #endif
                        case LDNS_SIGN_HMACMD5:
index 93b017df74f8039c040b778438b73a5a1aac572b..1ffb0f51686cdebe9d36d69770a1e600c7a59fbb 100644 (file)
@@ -75,7 +75,7 @@ ldns_rr_list2buffer_wire(ldns_buffer *buffer,const ldns_rr_list *rr_list)
 
        rr_count = ldns_rr_list_rr_count(rr_list);
        for(i = 0; i < rr_count; i++) {
-               ldns_rr2buffer_wire(buffer, ldns_rr_list_rr(rr_list, i), 
+               (void)ldns_rr2buffer_wire(buffer, ldns_rr_list_rr(rr_list, i), 
                                          LDNS_SECTION_ANY);
        }
        return ldns_buffer_status(buffer);
@@ -323,7 +323,7 @@ ldns_pkt2buffer_wire(ldns_buffer *buffer, const ldns_pkt *packet)
                (void)ldns_rr2buffer_wire(buffer, edns_rr, LDNS_SECTION_ADDITIONAL);
                /* take the edns rdata back out of the rr before we free rr */
                if (packet->_edns_data)
-                       ldns_rr_pop_rdf (edns_rr);
+                       (void)ldns_rr_pop_rdf (edns_rr);
                ldns_rr_free(edns_rr);
        }
        
diff --git a/keys.c b/keys.c
index df9af56718cc55e063f19be2b0dc2dc26627fff7..c224cd6fe4f83d54aa05a91965021bd2ebfdeb78 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -96,6 +96,7 @@ ldns_key_new_frm_engine(ldns_key **key, ENGINE *e, char *key_id, ldns_algorithm
 
        k = ldns_key_new();
         if(!k) return LDNS_STATUS_MEM_ERR;
+#ifndef S_SPLINT_S
        k->_key.key = ENGINE_load_private_key(e, key_id, UI_OpenSSL(), NULL);
         if(!k->_key.key) {
                 ldns_key_free(k);
@@ -105,10 +106,10 @@ ldns_key_new_frm_engine(ldns_key **key, ENGINE *e, char *key_id, ldns_algorithm
        if (!k->_key.key) {
                 ldns_key_free(k);
                return LDNS_STATUS_ENGINE_KEY_NOT_LOADED;
-       } else {
-               *key = k;
-               return LDNS_STATUS_OK;
-       }
+       } 
+#endif /* splint */
+       *key = k;
+       return LDNS_STATUS_OK;
 }
 #endif
 
@@ -200,7 +201,7 @@ ldns_key_new_frm_fp_gost_l(FILE* fp, int* line_nr)
        if(ldns_str2rdf_b64(&b64rdf, token) != LDNS_STATUS_OK)
                return NULL;
        pp = (unsigned char*)ldns_rdf_data(b64rdf);
-       pkey = d2i_PrivateKey(gost_id, NULL, &pp, ldns_rdf_size(b64rdf));
+       pkey = d2i_PrivateKey(gost_id, NULL, &pp, (int)ldns_rdf_size(b64rdf));
        ldns_rdf_deep_free(b64rdf);
        return pkey;
 }
@@ -259,7 +260,7 @@ ldns_key_new_frm_fp_ecdsa_l(FILE* fp, ldns_algorithm alg, int* line_nr)
                ldns_rdf_deep_free(b64rdf);
                 return NULL;
         }
-       bn = BN_bin2bn(pp, ldns_rdf_size(b64rdf), NULL);
+       bn = BN_bin2bn(pp, (int)ldns_rdf_size(b64rdf), NULL);
        ldns_rdf_deep_free(b64rdf);
         if(!bn) {
                 EC_KEY_free(ec);
@@ -386,10 +387,10 @@ ldns_key_new_frm_fp_l(ldns_key **key, FILE *fp, int *line_nr)
        }
 #ifdef USE_ECDSA
        if (strncmp(d, "13 ECDSAP256SHA256", 3) == 0) {
-                alg = LDNS_ECDSAP256SHA256;
+                alg = LDNS_SIGN_ECDSAP256SHA256;
         }
        if (strncmp(d, "14 ECDSAP384SHA384", 3) == 0) {
-                alg = LDNS_ECDSAP384SHA384;
+                alg = LDNS_SIGN_ECDSAP384SHA384;
         }
 #endif
        if (strncmp(d, "157 HMAC-MD5", 4) == 0) {
@@ -407,7 +408,7 @@ ldns_key_new_frm_fp_l(ldns_key **key, FILE *fp, int *line_nr)
        switch(alg) {
                case LDNS_SIGN_RSAMD5:
                case LDNS_SIGN_RSASHA1:
-               case LDNS_RSASHA1_NSEC3:
+               case LDNS_SIGN_RSASHA1_NSEC3:
 #ifdef USE_SHA2
                case LDNS_SIGN_RSASHA256:
                case LDNS_SIGN_RSASHA512:
@@ -424,7 +425,7 @@ ldns_key_new_frm_fp_l(ldns_key **key, FILE *fp, int *line_nr)
 #endif /* HAVE_SSL */
                        break;
                case LDNS_SIGN_DSA:
-               case LDNS_DSA_NSEC3:
+               case LDNS_SIGN_DSA_NSEC3:
                        ldns_key_set_algorithm(k, alg);
 #ifdef HAVE_SSL
                        dsa = ldns_key_new_frm_fp_dsa_l(fp, line_nr);
@@ -459,10 +460,12 @@ ldns_key_new_frm_fp_l(ldns_key **key, FILE *fp, int *line_nr)
                         }
                        ldns_key_set_evp_key(k, 
                                ldns_key_new_frm_fp_gost_l(fp, line_nr));
+#ifndef S_SPLINT_S
                        if(!k->_key.key) {
                                ldns_key_free(k);
                                return LDNS_STATUS_ERR;
                        }
+#endif /* splint */
 #endif
                        break;
 #ifdef USE_ECDSA
@@ -470,11 +473,13 @@ ldns_key_new_frm_fp_l(ldns_key **key, FILE *fp, int *line_nr)
                case LDNS_SIGN_ECDSAP384SHA384:
                         ldns_key_set_algorithm(k, alg);
                         ldns_key_set_evp_key(k,
-                                ldns_key_new_frm_fp_ecdsa_l(fp, alg, line_nr));
+                                ldns_key_new_frm_fp_ecdsa_l(fp, (ldns_algorithm)alg, line_nr));
+#ifndef S_SPLINT_S
                        if(!k->_key.key) {
                                ldns_key_free(k);
                                return LDNS_STATUS_ERR;
                        }
+#endif /* splint */
                        break;
 #endif
                default:
@@ -548,6 +553,7 @@ ldns_key_new_frm_fp_rsa_l(FILE *f, int *line_nr)
                goto error;
        }
        i = ldns_b64_pton((const char*)d, buf, ldns_b64_ntop_calculate_size(strlen(d)));
+#ifndef S_SPLINT_S
        rsa->n = BN_bin2bn((const char unsigned*)buf, i, NULL);
        if (!rsa->n) {
                goto error;
@@ -622,6 +628,7 @@ ldns_key_new_frm_fp_rsa_l(FILE *f, int *line_nr)
        if (!rsa->iqmp) {
                goto error;
        }
+#endif /* splint */
 
        LDNS_FREE(buf);
        LDNS_FREE(d);
@@ -664,6 +671,7 @@ ldns_key_new_frm_fp_dsa_l(FILE *f, int *line_nr)
                goto error;
        }
        i = ldns_b64_pton((const char*)d, buf, ldns_b64_ntop_calculate_size(strlen(d)));
+#ifndef S_SPLINT_S
        dsa->p = BN_bin2bn((const char unsigned*)buf, i, NULL);
        if (!dsa->p) {
                goto error;
@@ -708,6 +716,7 @@ ldns_key_new_frm_fp_dsa_l(FILE *f, int *line_nr)
        if (!dsa->pub_key) {
                goto error;
        }
+#endif /* splint */
 
        LDNS_FREE(buf);
        LDNS_FREE(d);
@@ -853,7 +862,9 @@ ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, uint16_t size)
                case LDNS_SIGN_HMACSHA1:
                case LDNS_SIGN_HMACSHA256:
 #ifdef HAVE_SSL
+#ifndef S_SPLINT_S
                        k->_key.key = NULL;
+#endif /* splint */
 #endif /* HAVE_SSL */
                        size = size / 8;
                        ldns_key_set_hmac_size(k, size);
@@ -887,15 +898,17 @@ ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, uint16_t size)
                case LDNS_SIGN_ECC_GOST:
 #if defined(HAVE_SSL) && defined(USE_GOST)
                        ldns_key_set_evp_key(k, ldns_gen_gost_key());
+#ifndef S_SPLINT_S
                         if(!k->_key.key) {
                                 ldns_key_free(k);
                                 return NULL;
                         }
+#endif /* splint */
 #endif /* HAVE_SSL and USE_GOST */
                         break;
 #ifdef USE_ECDSA
-                case LDNS_ECDSAP256SHA256:
-                case LDNS_ECDSAP384SHA384:
+                case LDNS_SIGN_ECDSAP256SHA256:
+                case LDNS_SIGN_ECDSAP384SHA384:
                         if(alg == LDNS_SIGN_ECDSAP256SHA256)
                                 ec = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
                         else if(alg == LDNS_SIGN_ECDSAP384SHA384)
@@ -909,6 +922,7 @@ ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, uint16_t size)
                                 EC_KEY_free(ec);
                                 return NULL;
                         }
+#ifndef S_SPLINT_S
                         k->_key.key = EVP_PKEY_new();
                         if(!k->_key.key) {
                                 ldns_key_free(k);
@@ -916,6 +930,7 @@ ldns_key_new_frm_algorithm(ldns_signing_algorithm alg, uint16_t size)
                                 return NULL;
                         }
                         EVP_PKEY_assign_EC_KEY(k->_key.key, ec);
+#endif /* splint */
                        break;
 #endif
        }
@@ -949,6 +964,7 @@ ldns_key_set_flags(ldns_key *k, uint16_t f)
 }
 
 #ifdef HAVE_SSL
+#ifndef S_SPLINT_S
 void
 ldns_key_set_evp_key(ldns_key *k, EVP_PKEY *e)
 {
@@ -970,6 +986,7 @@ ldns_key_set_dsa_key(ldns_key *k, DSA *d)
        EVP_PKEY_set1_DSA(key, d);
        k->_key.key  = key;
 }
+#endif /* splint */
 #endif /* HAVE_SSL */
 
 void
@@ -1061,6 +1078,7 @@ ldns_key_use(const ldns_key *k)
 }
 
 #ifdef HAVE_SSL
+#ifndef S_SPLINT_S
 EVP_PKEY *
 ldns_key_evp_key(const ldns_key *k)
 {
@@ -1086,6 +1104,7 @@ ldns_key_dsa_key(const ldns_key *k)
                return NULL;
        }
 }
+#endif /* splint */
 #endif /* HAVE_SSL */
 
 unsigned char *
@@ -1220,6 +1239,7 @@ ldns_key_list_pop_key(ldns_key_list *key_list)
 }       
 
 #ifdef HAVE_SSL
+#ifndef S_SPLINT_S
 /* data pointer must be large enough (LDNS_MAX_KEYLEN) */
 static bool
 ldns_key_rsa2bin(unsigned char *data, RSA *k, uint16_t *size)
@@ -1302,6 +1322,7 @@ ldns_key_gost2bin(unsigned char* data, EVP_PKEY* k, uint16_t* size)
        return true;
 }
 #endif /* USE_GOST */
+#endif /* splint */
 #endif /* HAVE_SSL */
 
 ldns_rr *
@@ -1354,11 +1375,11 @@ ldns_key2rr(const ldns_key *k)
 
        /* third - da algorithm */
        switch(ldns_key_algorithm(k)) {
-               case LDNS_RSAMD5:
-               case LDNS_RSASHA1:
-               case LDNS_RSASHA1_NSEC3:
-               case LDNS_RSASHA256:
-               case LDNS_RSASHA512:
+               case LDNS_SIGN_RSAMD5:
+               case LDNS_SIGN_RSASHA1:
+               case LDNS_SIGN_RSASHA1_NSEC3:
+               case LDNS_SIGN_RSASHA256:
+               case LDNS_SIGN_RSASHA512:
                        ldns_rr_push_rdf(pubkey,
                                                  ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k)));
 #ifdef HAVE_SSL
@@ -1401,7 +1422,7 @@ ldns_key2rr(const ldns_key *k)
                        }
 #endif /* HAVE_SSL */
                        break;
-               case LDNS_DSA_NSEC3:
+               case LDNS_SIGN_DSA_NSEC3:
                        ldns_rr_push_rdf(pubkey,
                                        ldns_native2rdf_int8(LDNS_RDF_TYPE_ALG, LDNS_DSA_NSEC3));
 #ifdef HAVE_SSL
@@ -1431,11 +1452,13 @@ ldns_key2rr(const ldns_key *k)
                                 ldns_rr_free(pubkey);
                                return NULL;
                         }
+#ifndef S_SPLINT_S
                        if (!ldns_key_gost2bin(bin, k->_key.key, &size)) {
                                LDNS_FREE(bin);
                                 ldns_rr_free(pubkey);
                                return NULL;
                        }
+#endif /* splint */
                        internal_data = 1;
 #endif /* HAVE_SSL and USE_GOST */
                        break;
@@ -1445,9 +1468,11 @@ ldns_key2rr(const ldns_key *k)
                        ldns_rr_push_rdf(pubkey, ldns_native2rdf_int8(
                                LDNS_RDF_TYPE_ALG, ldns_key_algorithm(k)));
                         bin = NULL;
+#ifndef S_SPLINT_S
                         ec = EVP_PKEY_get1_EC_KEY(k->_key.key);
+#endif
                         EC_KEY_set_conv_form(ec, POINT_CONVERSION_UNCOMPRESSED);
-                        size = i2o_ECPublicKey(ec, NULL);
+                        size = (uint16_t)i2o_ECPublicKey(ec, NULL);
                         if(!i2o_ECPublicKey(ec, &bin)) {
                                 EC_KEY_free(ec);
                                 ldns_rr_free(pubkey);
diff --git a/net.c b/net.c
index 85a8f506be89cf20c467bb0e0899b756857b77f2..bf8766b9905415ec261b780de5e7070e5b79194d 100644 (file)
--- a/net.c
+++ b/net.c
@@ -267,8 +267,10 @@ ldns_sock_wait(int sockfd, struct timeval timeout, int write)
 {
        fd_set fds;
        int ret;
+#ifndef S_SPLINT_S
        FD_ZERO(&fds);
        FD_SET(FD_SET_T sockfd, &fds);
+#endif
        if(write)
                ret = select(sockfd+1, NULL, &fds, NULL, &timeout);
        else
index 9177775b5bf925ec44bcc53f9e8f7d1c39de685e..217e61d27576fd5ad8fa3f517e1f79714927ecc6 100644 (file)
--- a/rbtree.c
+++ b/rbtree.c
@@ -629,7 +629,7 @@ ldns_rbtree_split(ldns_rbtree_t *tree,
        cur_node = ldns_rbtree_first(tree);
        while (count < elements && cur_node != LDNS_RBTREE_NULL) {
                move_node = ldns_rbtree_delete(tree, cur_node->key);
-               ldns_rbtree_insert(new_tree, move_node);
+               (void)ldns_rbtree_insert(new_tree, move_node);
                cur_node = ldns_rbtree_first(tree);
                count++;
        }
index 182add83cebd5db88d319941079dad4aa57d5e01..700372b91c85dff0a25fbda135357ab72d7d7b53 100644 (file)
@@ -334,7 +334,7 @@ ldns_rr_dnskey_key_size(const ldns_rr *key)
        if (!key) {
                return 0;
        }
-       return ldns_rr_dnskey_key_size_raw(ldns_rdf_data(ldns_rr_dnskey_key(key)),
+       return ldns_rr_dnskey_key_size_raw((unsigned char*)ldns_rdf_data(ldns_rr_dnskey_key(key)),
                                           ldns_rdf_size(ldns_rr_dnskey_key(key)),
                                           ldns_rdf2native_int8(ldns_rr_dnskey_algorithm(key))
                                          );
diff --git a/sha1.c b/sha1.c
index 7610d01f567db3fdc29ef5708f685a80206f5ebe..5dec680a1b795211570bada532e92024f5f89428 100644 (file)
--- a/sha1.c
+++ b/sha1.c
@@ -123,7 +123,7 @@ ldns_sha1_update(ldns_sha1_ctx *context, const unsigned char *data, unsigned int
     unsigned int i;
     unsigned int j;
 
-    j = (uint32_t)((context->count >> 3) & 63);
+    j = (unsigned)(uint32_t)((context->count >> 3) & 63);
     context->count += (len << 3);
     if ((j + len) > 63) {
         memmove(&context->buffer[j], data, (i = 64 - j));
@@ -156,7 +156,7 @@ ldns_sha1_final(unsigned char digest[LDNS_SHA1_DIGEST_LENGTH], ldns_sha1_ctx *co
     }
     ldns_sha1_update(context, finalcount, 8);  /* Should cause a SHA1Transform() */
 
-    if (digest)
+    if (digest != NULL)
         for (i = 0; i < LDNS_SHA1_DIGEST_LENGTH; i++) {
             digest[i] = (unsigned char)((context->state[i >> 2] >>
                 ((3 - (i & 3)) * 8)) & 255);
diff --git a/sha2.c b/sha2.c
index 62f5f6b8228edf6aec4e9480e06a330a12f0275d..26b7716a6623533b7ee28b458902d7463eaffef6 100644 (file)
--- a/sha2.c
+++ b/sha2.c
 
 typedef uint8_t  sha2_byte;    /* Exactly 1 byte */
 typedef uint32_t sha2_word32;  /* Exactly 4 bytes */
+#ifdef S_SPLINT_S
+typedef unsigned long long sha2_word64; /* lint 8 bytes */
+#else
 typedef uint64_t sha2_word64;  /* Exactly 8 bytes */
+#endif
 
 /*** SHA-256/384/512 Various Length Definitions ***********************/
 /* NOTE: Most of these are in sha2.h */
@@ -116,6 +120,7 @@ typedef uint64_t sha2_word64;       /* Exactly 8 bytes */
        tmp = (tmp >> 16) | (tmp << 16); \
        (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \
 }
+#ifndef S_SPLINT_S
 #define REVERSE64(w,x) { \
        sha2_word64 tmp = (w); \
        tmp = (tmp >> 32) | (tmp << 32); \
@@ -124,6 +129,9 @@ typedef uint64_t sha2_word64;       /* Exactly 8 bytes */
        (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \
              ((tmp & 0x0000ffff0000ffffULL) << 16); \
 }
+#else /* splint */
+#define REVERSE64(w,x) /* splint */
+#endif /* splint */
 #endif /* BYTE_ORDER == LITTLE_ENDIAN */
 
 /*
@@ -137,6 +145,10 @@ typedef uint64_t sha2_word64;      /* Exactly 8 bytes */
                (w)[1]++; \
        } \
 }
+#ifdef S_SPLINT_S
+#undef ADDINC128
+#define ADDINC128(w,n) /* splint */
+#endif
 
 /*
  * Macros for copying blocks of memory and for zeroing out ranges
@@ -487,7 +499,7 @@ static void ldns_sha256_Transform(ldns_sha256_CTX* context,
 #endif /* SHA2_UNROLL_TRANSFORM */
 
 void ldns_sha256_update(ldns_sha256_CTX* context, const sha2_byte *data, size_t len) {
-       unsigned int    freespace, usedspace;
+       size_t freespace, usedspace;
 
        if (len == 0) {
                /* Calling with no data is valid - we do nothing */
@@ -536,7 +548,7 @@ void ldns_sha256_update(ldns_sha256_CTX* context, const sha2_byte *data, size_t
 
 void ldns_sha256_final(sha2_byte digest[], ldns_sha256_CTX* context) {
        sha2_word32     *d = (sha2_word32*)digest;
-       unsigned int    usedspace;
+       size_t usedspace;
 
        /* Sanity check: */
        assert(context != (ldns_sha256_CTX*)0);
@@ -789,7 +801,7 @@ static void ldns_sha512_Transform(ldns_sha512_CTX* context,
 #endif /* SHA2_UNROLL_TRANSFORM */
 
 void ldns_sha512_update(ldns_sha512_CTX* context, const sha2_byte *data, size_t len) {
-       unsigned int    freespace, usedspace;
+       size_t freespace, usedspace;
 
        if (len == 0) {
                /* Calling with no data is valid - we do nothing */
@@ -837,7 +849,7 @@ void ldns_sha512_update(ldns_sha512_CTX* context, const sha2_byte *data, size_t
 }
 
 static void ldns_sha512_Last(ldns_sha512_CTX* context) {
-       unsigned int    usedspace;
+       size_t usedspace;
 
        usedspace = (context->bitcount[0] >> 3) % LDNS_SHA512_BLOCK_LENGTH;
 #if BYTE_ORDER == LITTLE_ENDIAN
index c4034537fdf97950f86b18c8fe20e68acf966a1f..b12f31f3b47cf24cf7355bfe4fa1cb4b7b4d8166 100644 (file)
@@ -135,7 +135,7 @@ ldns_str2rdf_nsec3_salt(ldns_rdf **rd, const char *salt_str)
                return LDNS_STATUS_NULL;
        }
 
-       salt_length_str = strlen(salt_str);
+       salt_length_str = (int)strlen(salt_str);
        if (salt_length_str == 1 && salt_str[0] == '-') {
                salt_length_str = 0;
        } else if (salt_length_str % 2 != 0) {
@@ -1191,13 +1191,13 @@ ldns_str2rdf_ipseckey(ldns_rdf **rd, const char *str)
        while(ldns_bget_token(str_buf, token, "\t\n ", strlen(str)) > 0) {
                switch (token_count) {
                                case 0:
-                                       precedence = atoi(token);
+                                       precedence = (uint8_t)atoi(token);
                                        break;
                                case 1:
-                                       gateway_type = atoi(token);
+                                       gateway_type = (uint8_t)atoi(token);
                                        break;
                                case 2:
-                                       algorithm = atoi(token);
+                                       algorithm = (uint8_t)atoi(token);
                                        break;
                                case 3:
                                        gateway = strdup(token);
@@ -1264,9 +1264,9 @@ ldns_str2rdf_ipseckey(ldns_rdf **rd, const char *str)
 
        /* now copy all into one ipseckey rdf */
        if (gateway_type)
-               ipseckey_len = 3 + ldns_rdf_size(gateway_rdf) + ldns_rdf_size(publickey_rdf);
+               ipseckey_len = 3 + (int)ldns_rdf_size(gateway_rdf) + (int)ldns_rdf_size(publickey_rdf);
        else
-               ipseckey_len = 3 + ldns_rdf_size(publickey_rdf);
+               ipseckey_len = 3 + (int)ldns_rdf_size(publickey_rdf);
 
        data = LDNS_XMALLOC(uint8_t, ipseckey_len);
        if(!data) {