]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix strchr() conformance to C23 1471/head
authorAlexander Bokovoy <abokovoy@redhat.com>
Wed, 10 Dec 2025 08:42:02 +0000 (10:42 +0200)
committerGreg Hudson <ghudson@mit.edu>
Tue, 20 Jan 2026 21:12:43 +0000 (16:12 -0500)
C23 7.28.5.1 specifies search functions such as strchr() as generic,
returning const char * if the first argument is of type const char *.
Fix uses of strchr() to conform to this change.

[jrische@redhat.com: altered changes to avoid casts; fixed an
additional case]
[ghudson@mit.edu: condensed some declarations; rewrote commit message]

ticket: 9191 (new)

src/lib/krb5/ccache/ccbase.c
src/lib/krb5/os/expand_path.c
src/lib/krb5/os/locate_kdc.c
src/plugins/preauth/pkinit/pkinit_crypto.h
src/plugins/preauth/pkinit/pkinit_crypto_openssl.c
src/plugins/preauth/pkinit/pkinit_identity.c
src/plugins/preauth/pkinit/pkinit_matching.c
src/tests/responder.c

index 696b681812d6bab1ba2245f6df2d3c7d39bac0fe..30a0a410c500bbce5ff4550009c20482ce101805 100644 (file)
@@ -201,8 +201,8 @@ krb5_cc_register(krb5_context context, const krb5_cc_ops *ops,
 krb5_error_code KRB5_CALLCONV
 krb5_cc_resolve (krb5_context context, const char *name, krb5_ccache *cache)
 {
-    char *pfx, *cp;
-    const char *resid;
+    char *pfx;
+    const char *cp, *resid;
     unsigned int pfxlen;
     krb5_error_code err;
     const krb5_cc_ops *ops;
index 5cbccf08c8bf0f14711b7ace31b4a5e9e077bba1..6569b8820bdbf0f2b5c8071b53ef418f5b543bb4 100644 (file)
@@ -454,7 +454,8 @@ k5_expand_path_tokens_extra(krb5_context context, const char *path_in,
 {
     krb5_error_code ret;
     struct k5buf buf;
-    char *tok_begin, *tok_end, *tok_val, **extra_tokens = NULL, *path;
+    const char *tok_begin, *tok_end;
+    char *tok_val, **extra_tokens = NULL, *path;
     const char *path_left;
     size_t nargs = 0, i;
     va_list ap;
index c186bce51c5a796fa3ec95f1a2d0fbc56678c217..0cceff800067079dc4ca0e27a067c5e7b65be8d8 100644 (file)
@@ -214,8 +214,8 @@ oom:
 }
 
 static void
-parse_uri_if_https(const char *host_or_uri, k5_transport *transport,
-                   const char **host, const char **uri_path)
+parse_uri_if_https(char *host_or_uri, k5_transport *transport,
+                   char **host, const char **uri_path)
 {
     char *cp;
 
@@ -257,8 +257,7 @@ locate_srv_conf_1(krb5_context context, const krb5_data *realm,
                   k5_transport transport, int udpport)
 {
     const char *realm_srv_names[4];
-    char **hostlist = NULL, *realmstr = NULL, *host = NULL;
-    const char *hostspec;
+    char **hostlist = NULL, *realmstr = NULL, *host = NULL, *hostspec;
     krb5_error_code code;
     size_t i;
     int default_port;
@@ -587,8 +586,8 @@ prof_locate_server(krb5_context context, const krb5_data *realm,
  * Return a NULL *host_out if there are any problems parsing the URI.
  */
 static void
-parse_uri_fields(const char *uri, k5_transport *transport_out,
-                 const char **host_out, int *primary_out)
+parse_uri_fields(char *uri, k5_transport *transport_out,
+                 char **host_out, int *primary_out)
 
 {
     k5_transport transport;
@@ -656,8 +655,8 @@ locate_uri(krb5_context context, const krb5_data *realm,
     krb5_error_code ret;
     k5_transport transport, host_trans;
     struct srv_dns_entry *answers, *entry;
-    char *host, *sitename;
-    const char *host_field, *path;
+    char *host, *sitename, *host_field;
+    const char *path;
     int port, def_port, primary;
 
     ret = get_sitename(context, realm, &sitename);
index 57bb3cb840ba44fb1f0619cbf28c9fcbb6955976..be2d02c227a4b574534b80e8e0bda5a23053fd6c 100644 (file)
@@ -440,7 +440,7 @@ krb5_error_code crypto_load_cas_and_crls
                    defines the storage type (file, directory, etc) */
        int catype,                                     /* IN
                    defines the ca type (anchor, intermediate, crls) */
-       char *id);                                      /* IN
+       const char *id);                                /* IN
                    defines the location (filename, directory name, etc) */
 
 /*
index bd25bae478910e512dd30ecfce293d0ba8317971..d1fe18e5abfef240ddc8f9d78485bd7898d08d6f 100644 (file)
@@ -4999,7 +4999,7 @@ load_cas_and_crls(krb5_context context,
                   pkinit_req_crypto_context req_cryptoctx,
                   pkinit_identity_crypto_context id_cryptoctx,
                   int catype,
-                  char *filename)
+                  const char *filename)
 {
     STACK_OF(X509_INFO) *sk = NULL;
     STACK_OF(X509) *ca_certs = NULL;
@@ -5157,7 +5157,7 @@ load_cas_and_crls_dir(krb5_context context,
                       pkinit_req_crypto_context req_cryptoctx,
                       pkinit_identity_crypto_context id_cryptoctx,
                       int catype,
-                      char *dirname)
+                      const char *dirname)
 {
     krb5_error_code retval = EINVAL;
     char **fnames = NULL, *filename;
@@ -5201,7 +5201,7 @@ crypto_load_cas_and_crls(krb5_context context,
                          pkinit_identity_crypto_context id_cryptoctx,
                          int idtype,
                          int catype,
-                         char *id)
+                         const char *id)
 {
     switch (idtype) {
     case IDTYPE_FILE:
index 0dcfcfc46a6863171f5c3781f5bc85f030e71bdd..ad65f237b072fae2c608df937d98767710f67c1f 100644 (file)
@@ -473,7 +473,7 @@ process_option_ca_crl(krb5_context context,
                       const char *value,
                       int catype)
 {
-    char *residual;
+    const char *residual;
     unsigned int typelen;
     int idtype;
 
index 0ea072c88766758f9c3eed36d266857ef0fb9ab4..b3c8df1610faca9cebeee2e9d94efce5e62859dc 100644 (file)
@@ -262,7 +262,7 @@ parse_rule_component(krb5_context context,
     char err_buf[128];
     int ret;
     struct keyword_desc *kw, *nextkw;
-    char *nk;
+    const char *nk;
     int found_next_kw = 0;
     char *value = NULL;
     size_t len;
index 82f870ea5d4b438395888f1b250b29f33645b427..4221a20283dab2674409b3046a17e65d041e48b4 100644 (file)
@@ -282,8 +282,7 @@ responder(krb5_context ctx, void *rawdata, krb5_responder_context rctx)
     /* Provide a particular response for an OTP challenge. */
     if (data->otp_answer != NULL) {
         if (krb5_responder_otp_get_challenge(ctx, rctx, &ochl) == 0) {
-            key = strchr(data->otp_answer, '=');
-            if (key != NULL) {
+            if (strchr(data->otp_answer, '=') != NULL) {
                 /* Make a copy of the answer that we can chop up. */
                 key = strdup(data->otp_answer);
                 if (key == NULL)