Skip to content

Commit 6b0a03f

Browse files
abbracryptomilk
authored andcommitted
Fix strchr() conformance to C23
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) (cherry picked from commit ad4dcf1856dadc4b352b5c8ff08e51c7290fb41f)
1 parent e75a082 commit 6b0a03f

8 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/lib/krb5/ccache/ccbase.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ krb5_cc_register(krb5_context context, const krb5_cc_ops *ops,
201201
krb5_error_code KRB5_CALLCONV
202202
krb5_cc_resolve (krb5_context context, const char *name, krb5_ccache *cache)
203203
{
204-
char *pfx, *cp;
205-
const char *resid;
204+
char *pfx;
205+
const char *cp, *resid;
206206
unsigned int pfxlen;
207207
krb5_error_code err;
208208
const krb5_cc_ops *ops;

src/lib/krb5/os/expand_path.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,8 @@ k5_expand_path_tokens_extra(krb5_context context, const char *path_in,
454454
{
455455
krb5_error_code ret;
456456
struct k5buf buf;
457-
char *tok_begin, *tok_end, *tok_val, **extra_tokens = NULL, *path;
457+
const char *tok_begin, *tok_end;
458+
char *tok_val, **extra_tokens = NULL, *path;
458459
const char *path_left;
459460
size_t nargs = 0, i;
460461
va_list ap;

src/lib/krb5/os/locate_kdc.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ add_host_to_list(struct serverlist *list, const char *hostname, int port,
214214
}
215215

216216
static void
217-
parse_uri_if_https(const char *host_or_uri, k5_transport *transport,
218-
const char **host, const char **uri_path)
217+
parse_uri_if_https(char *host_or_uri, k5_transport *transport,
218+
char **host, const char **uri_path)
219219
{
220220
char *cp;
221221

@@ -257,8 +257,7 @@ locate_srv_conf_1(krb5_context context, const krb5_data *realm,
257257
k5_transport transport, int udpport)
258258
{
259259
const char *realm_srv_names[4];
260-
char **hostlist = NULL, *realmstr = NULL, *host = NULL;
261-
const char *hostspec;
260+
char **hostlist = NULL, *realmstr = NULL, *host = NULL, *hostspec;
262261
krb5_error_code code;
263262
size_t i;
264263
int default_port;
@@ -587,8 +586,8 @@ prof_locate_server(krb5_context context, const krb5_data *realm,
587586
* Return a NULL *host_out if there are any problems parsing the URI.
588587
*/
589588
static void
590-
parse_uri_fields(const char *uri, k5_transport *transport_out,
591-
const char **host_out, int *primary_out)
589+
parse_uri_fields(char *uri, k5_transport *transport_out,
590+
char **host_out, int *primary_out)
592591

593592
{
594593
k5_transport transport;
@@ -656,8 +655,8 @@ locate_uri(krb5_context context, const krb5_data *realm,
656655
krb5_error_code ret;
657656
k5_transport transport, host_trans;
658657
struct srv_dns_entry *answers, *entry;
659-
char *host, *sitename;
660-
const char *host_field, *path;
658+
char *host, *sitename, *host_field;
659+
const char *path;
661660
int port, def_port, primary;
662661

663662
ret = get_sitename(context, realm, &sitename);

src/plugins/preauth/pkinit/pkinit_crypto.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ krb5_error_code crypto_load_cas_and_crls
440440
defines the storage type (file, directory, etc) */
441441
int catype, /* IN
442442
defines the ca type (anchor, intermediate, crls) */
443-
char *id); /* IN
443+
const char *id); /* IN
444444
defines the location (filename, directory name, etc) */
445445

446446
/*

src/plugins/preauth/pkinit/pkinit_crypto_openssl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5006,7 +5006,7 @@ load_cas_and_crls(krb5_context context,
50065006
pkinit_req_crypto_context req_cryptoctx,
50075007
pkinit_identity_crypto_context id_cryptoctx,
50085008
int catype,
5009-
char *filename)
5009+
const char *filename)
50105010
{
50115011
STACK_OF(X509_INFO) *sk = NULL;
50125012
STACK_OF(X509) *ca_certs = NULL;
@@ -5164,7 +5164,7 @@ load_cas_and_crls_dir(krb5_context context,
51645164
pkinit_req_crypto_context req_cryptoctx,
51655165
pkinit_identity_crypto_context id_cryptoctx,
51665166
int catype,
5167-
char *dirname)
5167+
const char *dirname)
51685168
{
51695169
krb5_error_code retval = EINVAL;
51705170
char **fnames = NULL, *filename;
@@ -5208,7 +5208,7 @@ crypto_load_cas_and_crls(krb5_context context,
52085208
pkinit_identity_crypto_context id_cryptoctx,
52095209
int idtype,
52105210
int catype,
5211-
char *id)
5211+
const char *id)
52125212
{
52135213
switch (idtype) {
52145214
case IDTYPE_FILE:

src/plugins/preauth/pkinit/pkinit_identity.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ process_option_ca_crl(krb5_context context,
473473
const char *value,
474474
int catype)
475475
{
476-
char *residual;
476+
const char *residual;
477477
unsigned int typelen;
478478
int idtype;
479479

src/plugins/preauth/pkinit/pkinit_matching.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ parse_rule_component(krb5_context context,
262262
char err_buf[128];
263263
int ret;
264264
struct keyword_desc *kw, *nextkw;
265-
char *nk;
265+
const char *nk;
266266
int found_next_kw = 0;
267267
char *value = NULL;
268268
size_t len;

src/tests/responder.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,7 @@ responder(krb5_context ctx, void *rawdata, krb5_responder_context rctx)
282282
/* Provide a particular response for an OTP challenge. */
283283
if (data->otp_answer != NULL) {
284284
if (krb5_responder_otp_get_challenge(ctx, rctx, &ochl) == 0) {
285-
key = strchr(data->otp_answer, '=');
286-
if (key != NULL) {
285+
if (strchr(data->otp_answer, '=') != NULL) {
287286
/* Make a copy of the answer that we can chop up. */
288287
key = strdup(data->otp_answer);
289288
if (key == NULL)

0 commit comments

Comments
 (0)