2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

fix: dev: Remove unnecessary operations

Decrementing optlen immediately before calling continue is unneccesary
and inconsistent with the rest of dns_message_pseudosectiontoyaml
and dns_message_pseudosectiontotext.  Coverity was also reporting
an impossible false positive overflow of optlen (CID 499061).

    4176                        } else if (optcode == DNS_OPT_CLIENT_TAG) {
    4177                                uint16_t id;
    4178                                ADD_STRING(target, "; CLIENT-TAG:");
    4179                                if (optlen == 2U) {
    4180                                        id = isc_buffer_getuint16(&optbuf);
    4181                                        snprintf(buf, sizeof(buf), " %u\n", id);
    4182                                        ADD_STRING(target, buf);

    CID 499061: (#1 of 1): Overflowed constant (INTEGER_OVERFLOW)
    overflow_const: Expression optlen, which is equal to 65534, underflows
    the type that receives it, an unsigned integer 16 bits wide.
    4183                                        optlen -= 2;
    4184                                        POST(optlen);
    4185                                        continue;
    4186                                }
    4187                        } else if (optcode == DNS_OPT_SERVER_TAG) {

Merge branch 'marka-remove-unnecessary-operations' into 'main'

See merge request isc-projects/bind9!9130
This commit is contained in:
Mark Andrews 2024-08-02 06:34:08 +00:00
commit 33f4ee7c36

View File

@ -3839,8 +3839,6 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
id = isc_buffer_getuint16(&optbuf);
snprintf(buf, sizeof(buf), " %u\n", id);
ADD_STRING(target, buf);
optlen -= 2;
POST(optlen);
continue;
}
} else if (optcode == DNS_OPT_SERVER_TAG) {
@ -3851,8 +3849,6 @@ dns_message_pseudosectiontoyaml(dns_message_t *msg, dns_pseudosection_t section,
id = isc_buffer_getuint16(&optbuf);
snprintf(buf, sizeof(buf), " %u\n", id);
ADD_STRING(target, buf);
optlen -= 2;
POST(optlen);
continue;
}
} else {
@ -4231,8 +4227,6 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
id = isc_buffer_getuint16(&optbuf);
snprintf(buf, sizeof(buf), " %u\n", id);
ADD_STRING(target, buf);
optlen -= 2;
POST(optlen);
continue;
}
} else if (optcode == DNS_OPT_SERVER_TAG) {
@ -4242,8 +4236,6 @@ dns_message_pseudosectiontotext(dns_message_t *msg, dns_pseudosection_t section,
id = isc_buffer_getuint16(&optbuf);
snprintf(buf, sizeof(buf), " %u\n", id);
ADD_STRING(target, buf);
optlen -= 2;
POST(optlen);
continue;
}
} else {