]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove unnecessary operations
authorMark Andrews <marka@isc.org>
Tue, 9 Jul 2024 00:29:30 +0000 (10:29 +1000)
committerMark Andrews <marka@isc.org>
Fri, 2 Aug 2024 06:43:03 +0000 (06:43 +0000)
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) {

(cherry picked from commit 47338c2c876970cdd8c0e07532b88bc65bf1ea3c)

lib/dns/message.c

index 213b6f529aab260ef187616cd9c1ceecf85fe203..67190af1f9489e6d473727bb7b541338b7aa326c 100644 (file)
@@ -3746,8 +3746,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) {
@@ -3758,8 +3756,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 {
@@ -4106,8 +4102,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) {
@@ -4117,8 +4111,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 {