3535uint16_t dnssec_keytag (DnsResourceRecord * dnskey , bool mask_revoke ) {
3636 const uint8_t * p ;
3737 uint32_t sum , f ;
38- size_t i ;
3938
4039 /* The algorithm from RFC 4034, Appendix B. */
4140
@@ -51,7 +50,7 @@ uint16_t dnssec_keytag(DnsResourceRecord *dnskey, bool mask_revoke) {
5150
5251 p = dnskey -> dnskey .key ;
5352
54- for (i = 0 ; i < dnskey -> dnskey .key_size ; i ++ )
53+ for (size_t i = 0 ; i < dnskey -> dnskey .key_size ; i ++ )
5554 sum += (i & 1 ) == 0 ? (uint32_t ) p [i ] << 8 : (uint32_t ) p [i ];
5655
5756 sum += (sum >> 16 ) & UINT32_C (0xFFFF );
@@ -483,14 +482,14 @@ static int dnssec_rrsig_prepare(DnsResourceRecord *rrsig) {
483482 const char * name ;
484483 int r ;
485484
486- /* Checks whether the specified RRSIG RR is somewhat valid, and initializes the .n_skip_labels_source and
487- * .n_skip_labels_signer fields so that we can use them later on. */
485+ /* Checks whether the specified RRSIG RR is somewhat valid, and initializes the .n_skip_labels_source
486+ * and .n_skip_labels_signer fields so that we can use them later on. */
488487
489488 assert (rrsig );
490489 assert (rrsig -> key -> type == DNS_TYPE_RRSIG );
491490
492491 /* Check if this RRSIG RR is already prepared */
493- if (rrsig -> n_skip_labels_source != UINT_MAX )
492+ if (rrsig -> n_skip_labels_source != UINT8_MAX )
494493 return 0 ;
495494
496495 if (rrsig -> rrsig .inception > rrsig -> rrsig .expiration )
@@ -523,6 +522,7 @@ static int dnssec_rrsig_prepare(DnsResourceRecord *rrsig) {
523522 if (r == 0 )
524523 return - EINVAL ;
525524
525+ assert (n_key_labels < UINT8_MAX ); /* UINT8_MAX/-1 means unsigned. */
526526 rrsig -> n_skip_labels_source = n_key_labels - rrsig -> rrsig .labels ;
527527 rrsig -> n_skip_labels_signer = n_key_labels - n_signer_labels ;
528528
@@ -604,13 +604,11 @@ static void dnssec_fix_rrset_ttl(
604604 DnsResourceRecord * rrsig ,
605605 usec_t realtime ) {
606606
607- unsigned k ;
608-
609607 assert (list );
610608 assert (n > 0 );
611609 assert (rrsig );
612610
613- for (k = 0 ; k < n ; k ++ ) {
611+ for (unsigned k = 0 ; k < n ; k ++ ) {
614612 DnsResourceRecord * rr = list [k ];
615613
616614 /* Pick the TTL as the minimum of the RR's TTL, the
@@ -640,7 +638,7 @@ int dnssec_verify_rrset(
640638 const char * source , * name ;
641639 _cleanup_ (gcry_md_closep ) gcry_md_hd_t md = NULL ;
642640 int r , md_algorithm ;
643- size_t k , n = 0 ;
641+ size_t n = 0 ;
644642 size_t sig_size = 0 ;
645643 _cleanup_free_ char * sig_data = NULL ;
646644 _cleanup_fclose_ FILE * f = NULL ;
@@ -770,7 +768,7 @@ int dnssec_verify_rrset(
770768 if (r < 0 )
771769 return r ;
772770
773- for (k = 0 ; k < n ; k ++ ) {
771+ for (size_t k = 0 ; k < n ; k ++ ) {
774772 size_t l ;
775773
776774 rr = list [k ];
@@ -1210,7 +1208,6 @@ int dnssec_nsec3_hash(DnsResourceRecord *nsec3, const char *name, void *ret) {
12101208 size_t hash_size ;
12111209 int algorithm ;
12121210 void * result ;
1213- unsigned k ;
12141211 int r ;
12151212
12161213 assert (nsec3 );
@@ -1252,7 +1249,7 @@ int dnssec_nsec3_hash(DnsResourceRecord *nsec3, const char *name, void *ret) {
12521249 if (!result )
12531250 return - EIO ;
12541251
1255- for (k = 0 ; k < nsec3 -> nsec3 .iterations ; k ++ ) {
1252+ for (unsigned k = 0 ; k < nsec3 -> nsec3 .iterations ; k ++ ) {
12561253 uint8_t tmp [hash_size ];
12571254 memcpy (tmp , result , hash_size );
12581255
@@ -1291,10 +1288,10 @@ static int nsec3_is_good(DnsResourceRecord *rr, DnsResourceRecord *nsec3) {
12911288
12921289 /* Ignore NSEC3 RRs generated from wildcards. If these NSEC3 RRs weren't correctly signed we can't make this
12931290 * check (since rr->n_skip_labels_source is -1), but that's OK, as we won't trust them anyway in that case. */
1294- if (!IN_SET (rr -> n_skip_labels_source , 0 , UINT_MAX ))
1291+ if (!IN_SET (rr -> n_skip_labels_source , 0 , UINT8_MAX ))
12951292 return 0 ;
12961293 /* Ignore NSEC3 RRs that are located anywhere else than one label below the zone */
1297- if (!IN_SET (rr -> n_skip_labels_signer , 1 , UINT_MAX ))
1294+ if (!IN_SET (rr -> n_skip_labels_signer , 1 , UINT8_MAX ))
12981295 return 0 ;
12991296
13001297 if (!nsec3 )
@@ -2234,24 +2231,24 @@ int dnssec_test_positive_wildcard(
22342231#endif
22352232
22362233static const char * const dnssec_result_table [_DNSSEC_RESULT_MAX ] = {
2237- [DNSSEC_VALIDATED ] = "validated" ,
2238- [DNSSEC_VALIDATED_WILDCARD ] = "validated-wildcard" ,
2239- [DNSSEC_INVALID ] = "invalid" ,
2240- [DNSSEC_SIGNATURE_EXPIRED ] = "signature-expired" ,
2234+ [DNSSEC_VALIDATED ] = "validated" ,
2235+ [DNSSEC_VALIDATED_WILDCARD ] = "validated-wildcard" ,
2236+ [DNSSEC_INVALID ] = "invalid" ,
2237+ [DNSSEC_SIGNATURE_EXPIRED ] = "signature-expired" ,
22412238 [DNSSEC_UNSUPPORTED_ALGORITHM ] = "unsupported-algorithm" ,
2242- [DNSSEC_NO_SIGNATURE ] = "no-signature" ,
2243- [DNSSEC_MISSING_KEY ] = "missing-key" ,
2244- [DNSSEC_UNSIGNED ] = "unsigned" ,
2245- [DNSSEC_FAILED_AUXILIARY ] = "failed-auxiliary" ,
2246- [DNSSEC_NSEC_MISMATCH ] = "nsec-mismatch" ,
2247- [DNSSEC_INCOMPATIBLE_SERVER ] = "incompatible-server" ,
2239+ [DNSSEC_NO_SIGNATURE ] = "no-signature" ,
2240+ [DNSSEC_MISSING_KEY ] = "missing-key" ,
2241+ [DNSSEC_UNSIGNED ] = "unsigned" ,
2242+ [DNSSEC_FAILED_AUXILIARY ] = "failed-auxiliary" ,
2243+ [DNSSEC_NSEC_MISMATCH ] = "nsec-mismatch" ,
2244+ [DNSSEC_INCOMPATIBLE_SERVER ] = "incompatible-server" ,
22482245};
22492246DEFINE_STRING_TABLE_LOOKUP (dnssec_result , DnssecResult );
22502247
22512248static const char * const dnssec_verdict_table [_DNSSEC_VERDICT_MAX ] = {
2252- [DNSSEC_SECURE ] = "secure" ,
2253- [DNSSEC_INSECURE ] = "insecure" ,
2254- [DNSSEC_BOGUS ] = "bogus" ,
2249+ [DNSSEC_SECURE ] = "secure" ,
2250+ [DNSSEC_INSECURE ] = "insecure" ,
2251+ [DNSSEC_BOGUS ] = "bogus" ,
22552252 [DNSSEC_INDETERMINATE ] = "indeterminate" ,
22562253};
22572254DEFINE_STRING_TABLE_LOOKUP (dnssec_verdict , DnssecVerdict );
0 commit comments