]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix conditional expressions with parentheses for bitwise and.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 11 Jun 2025 14:42:43 +0000 (16:42 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 11 Jun 2025 14:42:43 +0000 (16:42 +0200)
12 files changed:
compat/fake-rfc2553.c
dnstap/dnstap.c
doc/Changelog
iterator/iterator.c
services/outside_network.c
sldns/keyraw.c
sldns/str2wire.c
testcode/dohclient.c
util/data/dname.c
util/data/msgencode.c
util/data/msgreply.c
validator/validator.c

index 0f0f34f1fb2dea10c943207b271e3bd4280bfff9..45b703f2bce83027aea01b9b6dfde7eb0c3ada56 100644 (file)
@@ -57,7 +57,7 @@ int getnameinfo(const struct sockaddr *sa, size_t ATTR_UNUSED(salen), char *host
        }
 
        if (host != NULL) {
-               if (flags & NI_NUMERICHOST) {
+               if ((flags & NI_NUMERICHOST)) {
                        if (strlcpy(host, inet_ntoa(sin->sin_addr),
                            hostlen) >= hostlen)
                                return (EAI_MEMORY);
@@ -168,7 +168,7 @@ getaddrinfo(const char *hostname, const char *servname,
                        port = 0;
        }
 
-       if (hints && hints->ai_flags & AI_PASSIVE) {
+       if (hints && (hints->ai_flags & AI_PASSIVE)) {
                addr = htonl(0x00000000);
                if (hostname && inet_aton(hostname, &in) != 0)
                        addr = in.s_addr;
@@ -193,7 +193,7 @@ getaddrinfo(const char *hostname, const char *servname,
        }
        
        /* Don't try DNS if AI_NUMERICHOST is set */
-       if (hints && hints->ai_flags & AI_NUMERICHOST)
+       if (hints && (hints->ai_flags & AI_NUMERICHOST))
                return (EAI_NONAME);
        
        hp = gethostbyname(hostname);
index 071fd0895fe608ffe500da1a9ab1b9f67eb87c86..3b27301825c23025752adbb9d4b7e1c453400df4 100644 (file)
@@ -542,7 +542,7 @@ dt_msg_send_outside_query(struct dt_env *env,
        qflags = sldns_buffer_read_u16_at(qmsg, 2);
 
        /* type */
-       if (qflags & BIT_RD) {
+       if ((qflags & BIT_RD)) {
                if (!env->log_forwarder_query_messages)
                        return;
                dt_msg_init(env, &dm, DNSTAP__MESSAGE__TYPE__FORWARDER_QUERY);
@@ -599,7 +599,7 @@ dt_msg_send_outside_response(struct dt_env *env,
        qflags = ntohs(qflags);
 
        /* type */
-       if (qflags & BIT_RD) {
+       if ((qflags & BIT_RD)) {
                if (!env->log_forwarder_response_messages)
                        return;
                dt_msg_init(env, &dm, DNSTAP__MESSAGE__TYPE__FORWARDER_RESPONSE);
index 34c2fdcae4534a65e009ddb665b46c06b3f39947..432c993137090119acd8e147501111143f1cf573 100644 (file)
@@ -1,5 +1,6 @@
 11 June 2025: Wouter
        - Fix bitwise operators in conditional expressions with parentheses.
+       - Fix conditional expressions with parentheses for bitwise and.
 
 5 June 2025: Wouter
        - Fix unbound-anchor certificate file read for line ends and end of
index 320faf734c5805dbf1b39902836c41cd33d9ce28..0bf5523c5efae5f9359b76e4f1269dfe5f21a736 100644 (file)
@@ -4159,7 +4159,7 @@ processFinished(struct module_qstate* qstate, struct iter_qstate* iq,
                /* store message with the finished prepended items,
                 * but only if we did recursion. The nonrecursion referral
                 * from cache does not need to be stored in the msg cache. */
-               if(!qstate->no_cache_store && qstate->query_flags&BIT_RD) {
+               if(!qstate->no_cache_store && (qstate->query_flags&BIT_RD)) {
                        iter_dns_store(qstate->env, &qstate->qinfo, 
                                iq->response->rep, 0, qstate->prefetch_leeway,
                                iq->dp&&iq->dp->has_parent_side_NS,
index 0d7ec890573b7ffbd94c240620ca0625c49bba7c..2b7f7d0a2f21f8243aef3e7f3ebf7475c7431432 100644 (file)
@@ -2827,7 +2827,7 @@ serviced_perturb_qname(struct ub_randstate* rnd, uint8_t* qbuf, size_t len)
                                        random = ub_random(rnd);
                                        bits = 30;
                                }
-                               if(random & 0x1) {
+                               if((random & 0x1)) {
                                        *d = (uint8_t)toupper((unsigned char)*d);
                                } else {
                                        *d = (uint8_t)tolower((unsigned char)*d);
@@ -2890,9 +2890,9 @@ serviced_encode(struct serviced_query* sq, sldns_buffer* buff, int with_edns)
                edns.opt_list_inplace_cb_out = NULL;
                edns.udp_size = serviced_query_udp_size(sq, sq->status);
                edns.bits = 0;
-               if(sq->dnssec & EDNS_DO)
+               if((sq->dnssec & EDNS_DO))
                        edns.bits = EDNS_DO;
-               if(sq->dnssec & BIT_CD)
+               if((sq->dnssec & BIT_CD))
                        LDNS_CD_SET(sldns_buffer_begin(buff));
                if (sq->ssl_upstream && sq->padding_block_size) {
                        padding_option.opt_code = LDNS_EDNS_PADDING;
index 90a6e85337c2ea2e79859a6138eccf0c9d5ebbdf..cb6ed03872ee76bf63333741fe027a2e47ba517f 100644 (file)
@@ -124,7 +124,7 @@ uint16_t sldns_calc_keytag_raw(uint8_t* key, size_t keysize)
                size_t i;
                uint32_t ac32 = 0;
                for (i = 0; i < keysize; ++i) {
-                       ac32 += (i & 1) ? key[i] : key[i] << 8;
+                       ac32 += ((i & 1)) ? key[i] : key[i] << 8;
                }
                ac32 += (ac32 >> 16) & 0xFFFF;
                return (uint16_t) (ac32 & 0xFFFF);
index becd6d3855c9b81528e9f8611af6d80a5fc78652..392fc8f1d32a059b0aae2f7440b76aba7dfb77f5 100644 (file)
@@ -857,7 +857,7 @@ rrinternal_parse_rdata(sldns_buffer* strbuf, char* token, size_t token_len,
                while (rdata_len && *rdata != 0) {
                        uint8_t label_len;
 
-                       if (*rdata & 0xC0)
+                       if ((*rdata & 0xC0))
                                return LDNS_WIREPARSE_ERR_OK;
 
                        label_len = *rdata + 1;
index 2c12a5043f65d59531bebea48d6845f70ba6e97f..5eb523b2e0acc2b6907d14cc1667043334c3ef71 100644 (file)
@@ -388,7 +388,7 @@ static int http2_frame_recv_cb(nghttp2_session *session,
        }
        if(((frame->hd.type != NGHTTP2_DATA &&
                frame->hd.type != NGHTTP2_HEADERS) ||
-               frame->hd.flags & NGHTTP2_FLAG_END_STREAM) &&
+               (frame->hd.flags & NGHTTP2_FLAG_END_STREAM)) &&
                        h2_stream->res_status == 200) {
                        char* pktstr;
                        sldns_buffer_flip(h2_stream->buf);
index 2fe7b171df001dd3eec2d0bd5a59db05e803be96..d29a8e0345b14e2d391b553ad7791489b16f0469 100644 (file)
@@ -57,7 +57,7 @@ query_dname_len(sldns_buffer* query)
                if(sldns_buffer_remaining(query) < 1)
                        return 0; /* parse error, need label len */
                labellen = sldns_buffer_read_u8(query);
-               if(labellen&0xc0)
+               if((labellen&0xc0))
                        return 0; /* no compression allowed in queries */
                len += labellen + 1;
                if(len > LDNS_MAX_DOMAINLEN)
@@ -79,7 +79,7 @@ dname_valid(uint8_t* dname, size_t maxlen)
                return 0; /* too short, shortest is '0' root label */
        labellen = *dname++;
        while(labellen) {
-               if(labellen&0xc0)
+               if((labellen&0xc0))
                        return 0; /* no compression ptrs allowed */
                len += labellen + 1;
                if(len >= LDNS_MAX_DOMAINLEN)
index 6d116fb52d6d29204fd9cdb553faa05d666ec5a0..d229a7447e96f7531490c782fdf0ba02e56b9edb 100644 (file)
@@ -1021,7 +1021,7 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep,
                flags |= BIT_AA;
                flags &= ~BIT_AD;
        }
-       log_assert(flags & BIT_QR); /* QR bit must be on in our replies */
+       log_assert((flags & BIT_QR)); /* QR bit must be on in our replies */
        if(udpsize < LDNS_HEADER_SIZE)
                return 0;
        /* currently edns does not change during calculations;
index 35d768f9a4455d04b268895161b0722181a13d36..090490d7a44aa6323d3961ae5d6c3e1636c25155 100644 (file)
@@ -251,7 +251,7 @@ rdata_copy(sldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to,
 
        *rr_ttl = sldns_read_uint32(rr->ttl_data);
        /* RFC 2181 Section 8. if msb of ttl is set treat as if zero. */
-       if(*rr_ttl & 0x80000000U)
+       if((*rr_ttl & 0x80000000U))
                *rr_ttl = 0;
        if(type == LDNS_RR_TYPE_SOA && section == LDNS_SECTION_AUTHORITY) {
                /* negative response. see if TTL of SOA record larger than the
index a0550b484eaeb69db5a0e1a45068f5b67f099af3..7f8b19263641f431d5ebdf2e4d5a7737577f71df 100644 (file)
@@ -399,7 +399,7 @@ needs_validation(struct module_qstate* qstate, int ret_rc,
         * For DNS64 bit_cd signals no dns64 processing, but we want to
         * provide validation there too */
        /*
-       if(qstate->query_flags & BIT_CD) {
+       if((qstate->query_flags & BIT_CD)) {
                verbose(VERB_ALGO, "not validating response due to CD bit");
                return 0;
        }
@@ -2594,7 +2594,7 @@ processFinished(struct module_qstate* qstate, struct val_qstate* vq,
        /* Update rep->reason_bogus as it is the one being cached */
        update_reason_bogus(vq->orig_msg->rep, errinf_to_reason_bogus(qstate));
        /* store results in cache */
-       if(qstate->query_flags&BIT_RD) {
+       if((qstate->query_flags&BIT_RD)) {
                /* if secure, this will override cache anyway, no need
                 * to check if from parentNS */
                if(!qstate->no_cache_store) {