]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use const pointer with strchr of const pointer
authorMark Andrews <marka@isc.org>
Fri, 19 Dec 2025 01:32:33 +0000 (12:32 +1100)
committerMark Andrews (GitLab job 6746518) <marka@isc.org>
Tue, 20 Jan 2026 06:00:56 +0000 (06:00 +0000)
C23 now has qualifier preserving standard functions for strchr,
bsearch, strpbrk, strrchr, strstr, memchr.  There where a few places
where the return value was not assigned to a const qualified pointer.
These have been fixed.

(cherry picked from commit af379e10ccbede22a38cdbee58c6a71c097221d2)

bin/delv/delv.c
bin/tools/mdig.c
lib/isc/file.c

index 8348b7d31a3380ba74b56036395806714c6bf57f..4b238384e2226762577c79af8ecc3e2d6e88dccf 100644 (file)
@@ -1651,7 +1651,7 @@ append_str(const char *text, int len, char **p, char *end) {
 
 static isc_result_t
 reverse_octets(const char *in, char **p, char *end) {
-       char *dot = strchr(in, '.');
+       const char *dot = strchr(in, '.');
        int len;
        if (dot != NULL) {
                isc_result_t result;
index 90897574ff2879e1d3f6e0e405c50249c7228432..1c03297489b08931aea1d1e191c9dff58bf01ae3 100644 (file)
@@ -1658,7 +1658,7 @@ static bool
 dash_option(const char *option, char *next, struct query *query, bool global,
            bool *setname) {
        char opt;
-       const char *value;
+       const char *value, *oldvalue;
        isc_result_t result;
        bool value_from_next;
        isc_consttextregion_t tr;
@@ -1668,7 +1668,7 @@ dash_option(const char *option, char *next, struct query *query, bool global,
        struct in_addr in4;
        struct in6_addr in6;
        in_port_t srcport;
-       char *hash;
+       const char *hash;
        uint32_t num;
 
        while (strpbrk(option, single_dash_opts) == &option[0]) {
@@ -1739,12 +1739,15 @@ dash_option(const char *option, char *next, struct query *query, bool global,
        case 'b':
                GLOBAL();
                hash = strchr(value, '#');
+               oldvalue = value;
                if (hash != NULL) {
                        result = parse_uint(&num, hash + 1, MAXPORT,
                                            "port number");
                        CHECKM("parse_uint(srcport)", result);
                        srcport = num;
-                       *hash = '\0';
+                       snprintf(textname, sizeof(textname), "%.*s",
+                                (int)(hash - value), value);
+                       value = textname;
                } else {
                        srcport = 0;
                }
@@ -1755,13 +1758,7 @@ dash_option(const char *option, char *next, struct query *query, bool global,
                        isc_sockaddr_fromin(&srcaddr, &in4, srcport);
                        isc_net_disableipv6();
                } else {
-                       if (hash != NULL) {
-                               *hash = '#';
-                       }
-                       fatal("invalid address %s", value);
-               }
-               if (hash != NULL) {
-                       *hash = '#';
+                       fatal("invalid address %s", oldvalue);
                }
                have_src = true;
                return value_from_next;
index 3074e365536c679dec6d9a54d3448495dd6be3f3..c3edafc1fa96643557f401a73d5c61fbf87a29cf 100644 (file)
@@ -354,7 +354,7 @@ isc_file_openuniquemode(char *templet, int mode, FILE **fp) {
                        return isc__errno2result(errno);
                }
                for (cp = x;;) {
-                       char *t;
+                       const char *t;
                        if (*cp == '\0') {
                                return ISC_R_FAILURE;
                        }