mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-18 14:56:05 -05:00
- Fix conditional expressions with parentheses for bitwise and.
This commit is contained in:
parent
9f29292839
commit
a8aa1dbbe1
12 changed files with 19 additions and 18 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue