From e293353c4defb2e69ddd2c55e21a9eea300a322b Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 20 Jun 2023 12:22:05 +0000 Subject: [PATCH] appl/test: Sprinkle const and rk_UNCONST. --- appl/test/common.c | 6 +++--- appl/test/gssapi_client.c | 4 ++-- appl/test/gssapi_server.c | 6 ++++-- appl/test/http_client.c | 4 ++-- appl/test/nt_gss_client.c | 3 ++- appl/test/nt_gss_server.c | 4 ++-- appl/test/tcp_client.c | 5 +++-- appl/test/test_locl.h | 6 +++--- appl/test/uu_client.c | 6 ++++-- 9 files changed, 25 insertions(+), 19 deletions(-) diff --git a/appl/test/common.c b/appl/test/common.c index 3f0fc23f0..2abef3617 100644 --- a/appl/test/common.c +++ b/appl/test/common.c @@ -36,10 +36,10 @@ static int help_flag; static int version_flag; static char *port_str; -char *keytab_str; +const char *keytab_str; krb5_keytab keytab; -char *service = SERVICE; -char *mech = "krb5"; +const char *service = SERVICE; +const char *mech = "krb5"; int fork_flag; char *password = NULL; diff --git a/appl/test/gssapi_client.c b/appl/test/gssapi_client.c index 13049c800..2222bf691 100644 --- a/appl/test/gssapi_client.c +++ b/appl/test/gssapi_client.c @@ -50,7 +50,7 @@ do_trans (int sock, gss_ctx_id_t context_hdl) /* get_mic */ input_token->length = 3; - input_token->value = strdup("hej"); + input_token->value = rk_UNCONST("hej"); maj_stat = gss_get_mic(&min_stat, context_hdl, @@ -84,7 +84,7 @@ do_trans (int sock, gss_ctx_id_t context_hdl) /* wrap */ input_token->length = 7; - input_token->value = "hemligt"; + input_token->value = rk_UNCONST("hemligt"); maj_stat = gss_wrap (&min_stat, context_hdl, diff --git a/appl/test/gssapi_server.c b/appl/test/gssapi_server.c index 74ceb3bee..7da550d65 100644 --- a/appl/test/gssapi_server.c +++ b/appl/test/gssapi_server.c @@ -149,7 +149,8 @@ process_it(int sock, gss_release_buffer (&min_stat, input_token); gss_release_buffer (&min_stat, output_token); - input_token->value = "hejhej"; + /* used read-only by gss_wrap */ + input_token->value = rk_UNCONST("hejhej"); input_token->length = 6; maj_stat = gss_wrap (&min_stat, @@ -190,7 +191,8 @@ proto (int sock, const char *service) u_char init_buf[4]; u_char acct_buf[4]; gss_OID mech_oid; - char *mech, *p; + const char *mech; + char *p; memset(&remote, 0, sizeof(remote)); local = remote; diff --git a/appl/test/http_client.c b/appl/test/http_client.c index 23b3d5dac..35068722d 100644 --- a/appl/test/http_client.c +++ b/appl/test/http_client.c @@ -113,8 +113,8 @@ static int version_flag; static int verbose_flag; static int mutual_flag = 1; static int delegate_flag; -static char *port_str = "http"; -static char *gss_service = "HTTP"; +static const char *port_str = "http"; +static const char *gss_service = "HTTP"; static struct getargs http_args[] = { { "verbose", 'v', arg_flag, &verbose_flag, "verbose logging", NULL }, diff --git a/appl/test/nt_gss_client.c b/appl/test/nt_gss_client.c index fc9ff3c8d..740bd449c 100644 --- a/appl/test/nt_gss_client.c +++ b/appl/test/nt_gss_client.c @@ -140,7 +140,8 @@ proto (int sock, const char *hostname, const char *service) /* wrap */ input_token->length = 7; - input_token->value = "hemligt"; + /* used read-only by gss_wrap */ + input_token->value = rk_UNCONST("hemligt"); maj_stat = gss_wrap (&min_stat, diff --git a/appl/test/nt_gss_server.c b/appl/test/nt_gss_server.c index d6f7cc1be..435982438 100644 --- a/appl/test/nt_gss_server.c +++ b/appl/test/nt_gss_server.c @@ -50,8 +50,8 @@ RCSID("$Id$"); static int help_flag; static int version_flag; static char *port_str; -char *service = SERVICE; -static char *auth_file; +const char *service = SERVICE; +static const char *auth_file; static struct getargs args[] = { { "port", 'p', arg_string, &port_str, "port to listen to", "port" }, diff --git a/appl/test/tcp_client.c b/appl/test/tcp_client.c index 2bbb06811..9c0b0bc26 100644 --- a/appl/test/tcp_client.c +++ b/appl/test/tcp_client.c @@ -80,7 +80,8 @@ proto (int sock, const char *hostname, const char *service) if (status) krb5_err (context, 1, status, "krb5_sendauth"); - data.data = "hej"; + /* used read-only by krb5_mk_safe */ + data.data = rk_UNCONST("hej"); data.length = 3; krb5_data_zero (&packet); @@ -101,7 +102,7 @@ proto (int sock, const char *hostname, const char *service) if (krb5_net_write (context, &sock, packet.data, len) != len) err (1, "krb5_net_write"); - data.data = "hemligt"; + data.data = rk_UNCONST("hemligt"); data.length = 7; krb5_data_free (&packet); diff --git a/appl/test/test_locl.h b/appl/test/test_locl.h index dba2bba1b..778b55b89 100644 --- a/appl/test/test_locl.h +++ b/appl/test/test_locl.h @@ -78,9 +78,9 @@ #define PORT "test" -extern char *service; -extern char *mech; -extern char *keytab_str; +extern const char *service; +extern const char *mech; +extern const char *keytab_str; extern krb5_keytab keytab; extern int fork_flag; int server_setup(krb5_context*, int, char**); diff --git a/appl/test/uu_client.c b/appl/test/uu_client.c index 15e789973..d49441ac4 100644 --- a/appl/test/uu_client.c +++ b/appl/test/uu_client.c @@ -148,7 +148,8 @@ proto (int sock, const char *hostname, const char *service) } } - data.data = "hej"; + /* used read-only by krb5_mk_safe */ + data.data = rk_UNCONST("hej"); data.length = 3; krb5_data_zero (&packet); @@ -165,7 +166,8 @@ proto (int sock, const char *hostname, const char *service) if(status) krb5_err(context, 1, status, "krb5_write_message"); - data.data = "hemligt"; + /* used read-only by krb5_mk_priv */ + data.data = rk_UNCONST("hemligt"); data.length = 7; krb5_data_free (&packet);