From: "flichtenheld (Code Review)" Date: Wed, 6 May 2026 21:20:59 +0000 In-Reply-To: References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <88bcf6c416629e855d2ca819d05a726b36db1409-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="BfFWfMPAScY="; charset=UTF-8 Subject: [Openvpn-devel] [L] Change in openvpn[master]: Remove instances of constVariable/constVariablePointer cppcheck warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --BfFWfMPAScY= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1661?usp=3Demail to look at the new patch set (#3). Change subject: Remove instances of constVariable/constVariablePointer cppc= heck warnings ...................................................................... Remove instances of constVariable/constVariablePointer cppcheck warnings Of varied usefulness, but easier to just address all of them. Also change vpn_* parameters of dco_new_peer to const since that is required by one of the changes and it works (and would happen anyway when doing constParameterPointer). Change-Id: I2b71dae37ebe63c26a66761f877b25d326ed140f Signed-off-by: Frank Lichtenheld --- M dev-tools/cppcheck-suppression M sample/sample-plugins/defer/multi-auth.c M sample/sample-plugins/log/log.c M sample/sample-plugins/log/log_v3.c M sample/sample-plugins/simple/simple.c M src/openvpn/argv.c M src/openvpn/auth_token.c M src/openvpn/base64.c M src/openvpn/buffer.c M src/openvpn/buffer.h M src/openvpn/comp-lz4.c M src/openvpn/crypto.c M src/openvpn/crypto_epoch.c M src/openvpn/cryptoapi.c M src/openvpn/dco.c M src/openvpn/dco_freebsd.c M src/openvpn/dco_internal.h M src/openvpn/dco_linux.c M src/openvpn/dco_win.c M src/openvpn/dns.c M src/openvpn/forward.c M src/openvpn/init.c M src/openvpn/list.c M src/openvpn/manage.c M src/openvpn/misc.c M src/openvpn/mss.c M src/openvpn/mtcp.c M src/openvpn/mudp.c M src/openvpn/multi.c M src/openvpn/networking_sitnl.c M src/openvpn/options.c M src/openvpn/options_parse.c M src/openvpn/options_util.c M src/openvpn/pool.c M src/openvpn/proxy.c M src/openvpn/push.c M src/openvpn/route.c M src/openvpn/socket.c M src/openvpn/socket.h M src/openvpn/ssl.c M src/openvpn/ssl_mbedtls.c M src/openvpn/ssl_verify.c M src/openvpn/tun.c M src/openvpn/win32.c M src/openvpnmsica/msica_arg.c M src/openvpnmsica/openvpnmsica.c M src/plugins/auth-pam/auth-pam.c M src/tapctl/main.c M tests/unit_tests/openvpn/test_buffer.c M tests/unit_tests/openvpn/test_crypto.c M tests/unit_tests/openvpn/test_cryptoapi.c M tests/unit_tests/openvpn/test_misc.c M tests/unit_tests/openvpn/test_pkt.c M tests/unit_tests/openvpn/test_ssl.c M tests/unit_tests/plugins/auth-pam/test_search_and_replace.c 55 files changed, 155 insertions(+), 156 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/61/1661/3 diff --git a/dev-tools/cppcheck-suppression b/dev-tools/cppcheck-suppression index c9d4714..bb260c9 100644 --- a/dev-tools/cppcheck-suppression +++ b/dev-tools/cppcheck-suppression @@ -3,8 +3,6 @@ constParameter constParameterCallback constParameterPointer -constVariable -constVariablePointer variableScope # We have a lot of library includes, not all of them are really required, # so ignore them diff --git a/sample/sample-plugins/defer/multi-auth.c b/sample/sample-plugi= ns/defer/multi-auth.c index f6bbf44..33fbe61 100644 --- a/sample/sample-plugins/defer/multi-auth.c +++ b/sample/sample-plugins/defer/multi-auth.c @@ -399,7 +399,7 @@ OPENVPN_EXPORT void * openvpn_plugin_client_constructor_v1(openvpn_plugin_handle_t handle) { - struct plugin_context *context =3D (struct plugin_context *)handle; + const struct plugin_context *context =3D (struct plugin_context *)hand= le; plog(context, PLOG_NOTE, "FUNC: openvpn_plugin_client_constructor_v1"); return calloc(1, sizeof(struct plugin_per_client_context)); } @@ -407,7 +407,7 @@ OPENVPN_EXPORT void openvpn_plugin_client_destructor_v1(openvpn_plugin_handle_t handle, void *= per_client_context) { - struct plugin_context *context =3D (struct plugin_context *)handle; + const struct plugin_context *context =3D (struct plugin_context *)hand= le; plog(context, PLOG_NOTE, "FUNC: openvpn_plugin_client_destructor_v1"); free(per_client_context); } diff --git a/sample/sample-plugins/log/log.c b/sample/sample-plugins/log/lo= g.c index 330e3e0..76350ee 100644 --- a/sample/sample-plugins/log/log.c +++ b/sample/sample-plugins/log/log.c @@ -173,7 +173,7 @@ openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, con= st char *argv[], const char *envp[]) { - struct plugin_context *context =3D (struct plugin_context *)handle; + const struct plugin_context *context =3D (struct plugin_context *)hand= le; show(type, argv, envp); diff --git a/sample/sample-plugins/log/log_v3.c b/sample/sample-plugins/log= /log_v3.c index d2d44c7..09c6735 100644 --- a/sample/sample-plugins/log/log_v3.c +++ b/sample/sample-plugins/log/log_v3.c @@ -245,7 +245,7 @@ openvpn_plugin_func_v3(const int version, struct openvpn_plugin_args_func_= in const *args, struct openvpn_plugin_args_func_return *retptr) { - struct plugin_context *context =3D (struct plugin_context *)args->hand= le; + const struct plugin_context *context =3D (struct plugin_context *)args= ->handle; printf("\nopenvpn_plugin_func_v3() :::::>> "); show(args->type, args->argv, args->envp); diff --git a/sample/sample-plugins/simple/simple.c b/sample/sample-plugins/= simple/simple.c index 687a633..3182be0 100644 --- a/sample/sample-plugins/simple/simple.c +++ b/sample/sample-plugins/simple/simple.c @@ -104,7 +104,7 @@ openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, con= st char *argv[], const char *envp[]) { - struct plugin_context *context =3D (struct plugin_context *)handle; + const struct plugin_context *context =3D (struct plugin_context *)hand= le; /* get username/password from envp string array */ const char *username =3D get_env("username", envp); diff --git a/src/openvpn/argv.c b/src/openvpn/argv.c index 6a5d92e..028671d 100644 --- a/src/openvpn/argv.c +++ b/src/openvpn/argv.c @@ -359,7 +359,7 @@ * */ size_t argc =3D argres->argc; - char *f =3D argv_prep_format(format, delim, &argc, &argres->gc); + const char *f =3D argv_prep_format(format, delim, &argc, &argres->gc); if (f =3D=3D NULL) { goto out; diff --git a/src/openvpn/auth_token.c b/src/openvpn/auth_token.c index d8ca125..0cfcd2d 100644 --- a/src/openvpn/auth_token.c +++ b/src/openvpn/auth_token.c @@ -217,7 +217,7 @@ * a new token with the empty username since we do not want to loose * the information that the username cannot be trusted */ - struct key_state *ks =3D &multi->session[TM_ACTIVE].key[KS_PRIMARY]; + const struct key_state *ks =3D &multi->session[TM_ACTIVE].key[KS_PRIMA= RY]; if (ks->auth_token_state_flags & AUTH_TOKEN_VALID_EMPTYUSER) { hmac_ctx_update(ctx, (const uint8_t *)"", 0); diff --git a/src/openvpn/base64.c b/src/openvpn/base64.c index 7af8976..5752844 100644 --- a/src/openvpn/base64.c +++ b/src/openvpn/base64.c @@ -161,7 +161,7 @@ { const char *p; unsigned char *q; - unsigned char *e =3D NULL; + const unsigned char *e =3D NULL; q =3D data; if (size >=3D 0) diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index ee50dc5..131e1d6 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -536,7 +536,7 @@ void buf_null_terminate(struct buffer *buf) { - char *last =3D (char *)BLAST(buf); + const char *last =3D (char *)BLAST(buf); if (last && *last =3D=3D '\0') /* already terminated? */ { return; @@ -559,7 +559,7 @@ { while (true) { - char *last =3D (char *)BLAST(buf); + const char *last =3D (char *)BLAST(buf); if (!last) { break; diff --git a/src/openvpn/buffer.h b/src/openvpn/buffer.h index b4e65ef..6a751ad 100644 --- a/src/openvpn/buffer.h +++ b/src/openvpn/buffer.h @@ -712,7 +712,7 @@ static inline bool buf_copy_n(struct buffer *dest, struct buffer *src, int n) { - uint8_t *cp =3D buf_read_alloc(src, n); + const uint8_t *cp =3D buf_read_alloc(src, n); if (!cp) { return false; @@ -764,7 +764,7 @@ static inline bool buf_read(struct buffer *src, void *dest, int size) { - uint8_t *cp =3D buf_read_alloc(src, size); + const uint8_t *cp =3D buf_read_alloc(src, size); if (!cp) { return false; diff --git a/src/openvpn/comp-lz4.c b/src/openvpn/comp-lz4.c index 45f138c..48797b0 100644 --- a/src/openvpn/comp-lz4.c +++ b/src/openvpn/comp-lz4.c @@ -164,7 +164,7 @@ ASSERT(buf_init(&work, frame->buf.headroom)); /* do unframing/swap (assumes buf->len > 0) */ - uint8_t *head =3D BPTR(buf); + const uint8_t *head =3D BPTR(buf); c =3D *head; /* Not compressed */ diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c index df9b905..a9a33c0 100644 --- a/src/openvpn/crypto.c +++ b/src/openvpn/crypto.c @@ -1210,7 +1210,7 @@ /* init implicit IV */ { - cipher_ctx_t *cipher =3D co->key_ctx_bi.encrypt.cipher; + const cipher_ctx_t *cipher =3D co->key_ctx_bi.encrypt.cipher; if (cipher_ctx_mode_aead(cipher)) { ASSERT(cipher_ctx_iv_length(cipher) <=3D OPENVPN_MAX_IV_LENGTH= ); @@ -1919,7 +1919,7 @@ const char *seed =3D "tls1-prf-test"; const char *secret =3D "tls1-prf-test-secret"; uint8_t out[8]; - uint8_t expected_out[] =3D { 'q', 'D', 0xfe, '%', '@', 's', 'u', 0x95 = }; + const uint8_t expected_out[] =3D { 'q', 'D', 0xfe, '%', '@', 's', 'u',= 0x95 }; int ret =3D ssl_tls1_PRF((uint8_t *)seed, strlen(seed), (uint8_t *)sec= ret, strlen(secret), out, sizeof(out)); diff --git a/src/openvpn/crypto_epoch.c b/src/openvpn/crypto_epoch.c index 54225bf..3812435 100644 --- a/src/openvpn/crypto_epoch.c +++ b/src/openvpn/crypto_epoch.c @@ -213,7 +213,7 @@ * * The last generated key might have been moved to the decrypt key alr= eady. */ - struct key_ctx *highest_future_key =3D + const struct key_ctx *highest_future_key =3D &co->epoch_data_keys_future[co->epoch_data_keys_future_count - 1]; ASSERT(co->epoch_key_recv.epoch =3D=3D 1 || highest_future_key->epoch = =3D=3D co->epoch_key_recv.epoch diff --git a/src/openvpn/cryptoapi.c b/src/openvpn/cryptoapi.c index e17936a..543a1b3 100644 --- a/src/openvpn/cryptoapi.c +++ b/src/openvpn/cryptoapi.c @@ -223,7 +223,6 @@ const CERT_INFO *info =3D cert_ctx->pCertInfo; const CERT_EXTENSION *ext; DWORD cbext; - void *pvext; struct gc_arena gc =3D gc_new(); const WCHAR *tmpl_name =3D wide_string(cert_prop, &gc); @@ -231,7 +230,7 @@ ext =3D CertFindExtension(szOID_CERTIFICATE_TEMPLATE, info->cExtension= , info->rgExtension); if (ext) { - pvext =3D decode_object(&gc, X509_CERTIFICATE_TEMPLATE, &ext->Valu= e, 0, &cbext); + const void *pvext =3D decode_object(&gc, X509_CERTIFICATE_TEMPLATE= , &ext->Value, 0, &cbext); if (pvext && cbext >=3D sizeof(CERT_TEMPLATE_EXT)) { const CERT_TEMPLATE_EXT *cte =3D (const CERT_TEMPLATE_EXT *)pv= ext; diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index f5b7081..69ce1d7 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -109,7 +109,7 @@ for (int i =3D 0; i < KEY_SCAN_SIZE; ++i) { struct key_state *ks =3D get_key_scan(multi, i); - struct key_ctx_bi *key =3D &ks->crypto_options.key_ctx_bi; + const struct key_ctx_bi *key =3D &ks->crypto_options.key_ctx_bi; if (ks =3D=3D primary) { @@ -560,7 +560,7 @@ struct sockaddr_storage *local) { #if ENABLE_IP_PKTINFO - struct context *c =3D &mi->context; + const struct context *c =3D &mi->context; if (!proto_is_udp(c->c2.link_sockets[0]->info.proto) || !(c->options.sockflags & SF_USE_IP_PKTINFO)) @@ -608,7 +608,7 @@ int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi) { - struct context *c =3D &mi->context; + const struct context *c =3D &mi->context; int peer_id =3D c->c2.tls_multi->peer_id; struct sockaddr *remoteaddr, *localaddr =3D NULL; @@ -629,14 +629,14 @@ /* In server mode we need to fetch the remote addresses from the push = config */ struct in_addr vpn_ip4 =3D { 0 }; - struct in_addr *vpn_addr4 =3D NULL; + const struct in_addr *vpn_addr4 =3D NULL; if (c->c2.push_ifconfig_defined) { vpn_ip4.s_addr =3D htonl(c->c2.push_ifconfig_local); vpn_addr4 =3D &vpn_ip4; } =20 - struct in6_addr *vpn_addr6 =3D NULL; + const struct in6_addr *vpn_addr6 =3D NULL; if (c->c2.push_ifconfig_ipv6_defined) { vpn_addr6 =3D &c->c2.push_ifconfig_ipv6_local; @@ -685,7 +685,7 @@ } #endif - struct context *c =3D &mi->context; + const struct context *c =3D &mi->context; if (addrtype =3D=3D MR_ADDR_IPV6) { #if defined(_WIN32) @@ -733,7 +733,7 @@ } ASSERT(TUNNEL_TYPE(mi->context.c1.tuntap) =3D=3D DEV_TYPE_TUN); - struct context *c =3D &mi->context; + const struct context *c =3D &mi->context; if (mi->context.c2.push_ifconfig_defined) { diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index eaca86b..d933aaf 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -134,7 +134,8 @@ int dco_new_peer(dco_context_t *dco, unsigned int peerid, int sd, struct socka= ddr *localaddr, - struct sockaddr *remoteaddr, struct in_addr *vpn_ipv4, struct= in6_addr *vpn_ipv6) + struct sockaddr *remoteaddr, const struct in_addr *vpn_ipv4, + const struct in6_addr *vpn_ipv6) { struct ifdrv drv; nvlist_t *nvl, *local_nvl, *remote_nvl; diff --git a/src/openvpn/dco_internal.h b/src/openvpn/dco_internal.h index da07780..fcf8aca 100644 --- a/src/openvpn/dco_internal.h +++ b/src/openvpn/dco_internal.h @@ -60,7 +60,7 @@ */ int dco_new_peer(dco_context_t *dco, unsigned int peerid, socket_descripto= r_t sd, struct sockaddr *localaddr, - struct sockaddr *remoteaddr, struct in_addr *vpn_ipv4, st= ruct in6_addr *vpn_ipv6); + struct sockaddr *remoteaddr, const struct in_addr *vpn_ip= v4, const struct in6_addr *vpn_ipv6); int dco_del_peer(dco_context_t *dco, unsigned int peerid); diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 40746bd..56f6259 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -222,7 +222,8 @@ int dco_new_peer(dco_context_t *dco, unsigned int peerid, int sd, struct socka= ddr *localaddr, - struct sockaddr *remoteaddr, struct in_addr *vpn_ipv4, struct= in6_addr *vpn_ipv6) + struct sockaddr *remoteaddr, const struct in_addr *vpn_ipv4, + const struct in6_addr *vpn_ipv6) { struct gc_arena gc =3D gc_new(); const char *remotestr =3D "[undefined]"; @@ -697,7 +698,7 @@ { dco_context_t *dco =3D arg; struct nlattr *tb[CTRL_ATTR_MAX + 1]; - struct genlmsghdr *gnlh =3D nlmsg_data(nlmsg_hdr(msg)); + const struct genlmsghdr *gnlh =3D nlmsg_data(nlmsg_hdr(msg)); nla_parse(tb, CTRL_ATTR_MAX, genlmsg_attrdata(gnlh, 0), genlmsg_attrle= n(gnlh, 0), NULL); @@ -706,7 +707,7 @@ return NL_SKIP; } - struct nlattr *mcgrp; + const struct nlattr *mcgrp; int rem_mcgrp; nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcgrp) { diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index 2e26f2a..0d375d8 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -285,8 +285,8 @@ msg(D_DCO_DEBUG, "%s", __func__); int ai_family =3D sock->info.lsa->bind_local->ai_family; - struct addrinfo *local =3D sock->info.lsa->bind_local; - struct addrinfo *cur =3D NULL; + const struct addrinfo *local =3D sock->info.lsa->bind_local; + const struct addrinfo *cur =3D NULL; for (cur =3D local; cur; cur =3D cur->ai_next) { @@ -334,7 +334,7 @@ struct addrinfo *remoteaddr =3D sock->info.lsa->current_remote; struct sockaddr *local =3D NULL; - struct sockaddr *remote =3D remoteaddr->ai_addr; + const struct sockaddr *remote =3D remoteaddr->ai_addr; if (remoteaddr->ai_protocol =3D=3D IPPROTO_TCP || remoteaddr->ai_sockt= ype =3D=3D SOCK_STREAM) { @@ -348,7 +348,7 @@ if (sock->bind_local) { /* Use first local address with correct address family */ - struct addrinfo *bind =3D sock->info.lsa->bind_local; + const struct addrinfo *bind =3D sock->info.lsa->bind_local; while (bind && !local) { if (bind->ai_family =3D=3D remote->sa_family) @@ -415,8 +415,9 @@ } int -dco_new_peer(dco_context_t *dco, unsigned int peerid, socket_descriptor_t = sd, struct sockaddr *localaddr, - struct sockaddr *remoteaddr, struct in_addr *vpn_ipv4, struct= in6_addr *vpn_ipv6) +dco_new_peer(dco_context_t *dco, unsigned int peerid, socket_descriptor_t = sd, + struct sockaddr *localaddr, struct sockaddr *remoteaddr, + const struct in_addr *vpn_ipv4, const struct in6_addr *vpn_ip= v6) { msg(D_DCO_DEBUG, "%s: peer-id %d, fd " SOCKET_PRINTF, __func__, peerid= , sd); diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c index 954ed52..1bbb34e 100644 --- a/src/openvpn/dns.c +++ b/src/openvpn/dns.c @@ -132,7 +132,7 @@ } else { - struct sockaddr_in6 *sin6 =3D (struct sockaddr_in6 *)ai->ai_addr; + const struct sockaddr_in6 *sin6 =3D (struct sockaddr_in6 *)ai->ai_= addr; server->addr[server->addr_count].in.a6 =3D sin6->sin6_addr; } @@ -156,7 +156,7 @@ /* Append all domains to the end of the list */ while (*domains) { - char *domain =3D *domains++; + const char *domain =3D *domains++; if (!validate_domain(domain)) { return false; @@ -699,7 +699,7 @@ run_up_down_command(bool up, struct options *o, const struct tuntap *tt, struct dns_updown_runner_info *updown_runner) { - struct dns_options *dns =3D &o->dns_options; + const struct dns_options *dns =3D &o->dns_options; if (!dns->updown || (o->up_script && !dns_updown_user_set(dns) && !dns= _updown_forced(dns))) { return; @@ -864,7 +864,7 @@ } #ifdef _WIN32 /* Don't use iservice in DHCP mode */ - struct tuntap_options *tto =3D &o->tuntap_options; + const struct tuntap_options *tto =3D &o->tuntap_options; if (tto->ip_win32_type =3D=3D IPW32_SET_DHCP_MASQ || tto->ip_win32_typ= e =3D=3D IPW32_SET_ADAPTIVE) { return; diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 53eab4d..a4747ed 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -1215,7 +1215,7 @@ { if (float_sa->sa_family =3D=3D AF_INET) { - struct sockaddr_in *float4 =3D (struct sockaddr_in *)float_sa; + const struct sockaddr_in *float4 =3D (struct sockaddr_in *)float_s= a; /* DCO treats IPv4-mapped IPv6 addresses as pure IPv4. However, on= a * dual-stack socket, we need to preserve the mapping otherwise op= envpn * will not be able to find the peer by its transport address. @@ -1238,7 +1238,7 @@ } else { - struct sockaddr_in6 *float6 =3D (struct sockaddr_in6 *)float_sa; + const struct sockaddr_in6 *float6 =3D (struct sockaddr_in6 *)float= _sa; memcpy(&out_osaddr->addr.in6, float6, sizeof(struct sockaddr_in6)); } } @@ -1369,7 +1369,7 @@ } struct openvpn_sockaddr *link_addr =3D &c->c2.to_link_addr->dest; - struct link_socket_info *lsi =3D get_link_socket_info(c); + const struct link_socket_info *lsi =3D get_link_socket_info(c); int ip_hdr_offset =3D 0; int tun_ip_ver =3D get_tun_ip_ver(TUNNEL_TYPE(c->c1.tuntap), buf, &ip_= hdr_offset); @@ -2241,7 +2241,7 @@ if (e->arg >=3D MULTI_N) { - struct event_arg *ev_arg =3D (struct event_arg *)e= ->arg; + const struct event_arg *ev_arg =3D (struct event_a= rg *)e->arg; if (ev_arg->type !=3D EVENT_ARG_LINK_SOCKET) { c->c2.event_set_status =3D ES_ERROR; diff --git a/src/openvpn/init.c b/src/openvpn/init.c index caaa769..0861cb5 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -319,8 +319,8 @@ management_callback_remote_entry_count(void *arg) { ASSERT(arg); - struct context *c =3D (struct context *)arg; - struct connection_list *l =3D c->options.connection_list; + const struct context *c =3D (struct context *)arg; + const struct connection_list *l =3D c->options.connection_list; return l->len; } @@ -342,7 +342,7 @@ if (index < l->len) { - struct connection_entry *ce =3D l->array[index]; + const struct connection_entry *ce =3D l->array[index]; const char *proto =3D proto2ascii(ce->proto, ce->af, false); const char *status =3D (ce->flags & CE_DISABLED) ? "disabled" : "e= nabled"; @@ -525,7 +525,7 @@ { struct connection_list *l =3D c->options.connection_list; bool ce_defined; - struct connection_entry *ce; + const struct connection_entry *ce; int n_cycles =3D 0; do @@ -1581,10 +1581,10 @@ /* Tell management interface that we initialized */ if (management) { - in_addr_t *tun_local =3D NULL; - struct in6_addr *tun_local6 =3D NULL; + const in_addr_t *tun_local =3D NULL; + const struct in6_addr *tun_local6 =3D NULL; struct openvpn_sockaddr local, remote; - struct link_socket_actual *actual; + const struct link_socket_actual *actual; socklen_t sa_len =3D sizeof(local); const char *detail =3D "SUCCESS"; if (flags & ISC_ERRORS) @@ -4302,7 +4302,7 @@ /* On some newer Android handsets, changing to a different network * often does not trigger a TCP reset but continue using the old * connection (e.g. using mobile connection when WiFi becomes availabl= e */ - struct link_socket_info *lsi =3D get_link_socket_info(c); + const struct link_socket_info *lsi =3D get_link_socket_info(c); if (lsi && proto_is_tcp(lsi->proto) && !samenetwork) { return -2; diff --git a/src/openvpn/list.c b/src/openvpn/list.c index f0e9908..2e1cf05 100644 --- a/src/openvpn/list.c +++ b/src/openvpn/list.c @@ -165,7 +165,7 @@ hash_remove_by_value(struct hash *hash, void *value) { struct hash_iterator hi; - struct hash_element *he; + const struct hash_element *he; hash_iterator_init(hash, &hi); while ((he =3D hash_iterator_next(&hi))) diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index c082f51..604bbcd 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -3820,7 +3820,7 @@ { int ok; char *result =3D NULL; - struct buffer *buf; + const struct buffer *buf; ok =3D management_query_multiline(man, b64_data, prompt, cmd, state, i= nput); if (ok && buffer_list_defined(*input)) @@ -3849,7 +3849,7 @@ { int ok; char *result =3D NULL; - struct buffer *buf; + const struct buffer *buf; ok =3D management_query_multiline(man, b64_data, prompt, cmd, state, i= nput); if (ok && buffer_list_defined(*input)) diff --git a/src/openvpn/misc.c b/src/openvpn/misc.c index 10bfc35..6563b83 100644 --- a/src/openvpn/misc.c +++ b/src/openvpn/misc.c @@ -131,7 +131,7 @@ struct auth_challenge_info *ac; const int len =3D strlen(auth_challenge); char *work =3D (char *)gc_malloc(len + 1, false, gc); - char *cp; + const char *cp; struct buffer b; buf_set_read(&b, (const uint8_t *)auth_challenge, len); diff --git a/src/openvpn/mss.c b/src/openvpn/mss.c index 14112b4..36bbb43 100644 --- a/src/openvpn/mss.c +++ b/src/openvpn/mss.c @@ -65,7 +65,7 @@ struct buffer newbuf =3D *buf; if (buf_advance(&newbuf, hlen)) { - struct openvpn_tcphdr *tc =3D (struct openvpn_tcphdr *)BPTR(&n= ewbuf); + const struct openvpn_tcphdr *tc =3D (struct openvpn_tcphdr *)B= PTR(&newbuf); if (tc->flags & OPENVPN_TCPH_SYN_MASK) { mss_fixup_dowork(&newbuf, maxmss); @@ -122,7 +122,7 @@ newbuf =3D *buf; if (buf_advance(&newbuf, 40) && BLENZ(&newbuf) >=3D sizeof(struct open= vpn_tcphdr)) { - struct openvpn_tcphdr *tc =3D (struct openvpn_tcphdr *)BPTR(&newbu= f); + const struct openvpn_tcphdr *tc =3D (struct openvpn_tcphdr *)BPTR(= &newbuf); if (tc->flags & OPENVPN_TCPH_SYN_MASK) { mss_fixup_dowork(&newbuf, maxmss - 20); diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index 7651b4d..df94a70 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -130,7 +130,7 @@ void multi_tcp_dereference_instance(struct multi_io *multi_io, struct multi_ins= tance *mi) { - struct link_socket *sock =3D mi->context.c2.link_sockets[0]; + const struct link_socket *sock =3D mi->context.c2.link_sockets[0]; if (sock && mi->socket_set_called) { event_del(multi_io->es, socket_event_handle(sock)); diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 432c79a..50d72d5 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -74,7 +74,7 @@ verdict =3D tls_pre_decrypt_lite(tas, state, &m->top.c2.from, &m->top.= c2.buf); hmac_ctx_t *hmac =3D m->top.c2.session_id_hmac; - struct openvpn_sockaddr *from =3D &m->top.c2.from.dest; + const struct openvpn_sockaddr *from =3D &m->top.c2.from.dest; int handwindow =3D m->top.options.handshake_window; if (verdict =3D=3D VERDICT_VALID_RESET_V3 || verdict =3D=3D VERDICT_VA= LID_RESET_V2) @@ -201,7 +201,7 @@ struct hash_element *he; const uint32_t hv =3D hash_value(hash, &real); struct hash_bucket *bucket =3D hash_bucket(hash, hv); - uint8_t *ptr =3D BPTR(&m->top.c2.buf); + const uint8_t *ptr =3D BPTR(&m->top.c2.buf); uint8_t op =3D ptr[0] >> P_OPCODE_SHIFT; bool v2 =3D (op =3D=3D P_DATA_V2) && (m->top.c2.buf.len >=3D (1 + = 3)); bool peer_id_disabled =3D false; diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index a957fdf..ef39527 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -86,7 +86,7 @@ struct gc_arena gc =3D gc_new(); struct env_set *es; bool ret =3D true; - struct plugin_list *plugins; + const struct plugin_list *plugins; /* get environmental variable source */ if (mi && mi->context.c2.es) @@ -1794,7 +1794,7 @@ * Push the first cipher from --data-ciphers to the client that * the client announces to be supporting. */ - char *push_cipher =3D + const char *push_cipher =3D ncp_get_best_cipher(o->ncp_ciphers, peer_info, tls_multi->remote_c= iphername, &o->gc); if (push_cipher) { @@ -1925,7 +1925,7 @@ static enum client_connect_return ccs_test_deferred_ret_file(struct multi_instance *mi) { - struct client_connect_defer_state *ccs =3D &(mi->client_connect_defer_= state); + const struct client_connect_defer_state *ccs =3D &(mi->client_connect_= defer_state); FILE *fp =3D fopen(ccs->deferred_ret_file, "r"); if (!fp) { @@ -2166,7 +2166,7 @@ { ASSERT(mi); ASSERT(option_types_found); - struct client_connect_defer_state *ccs =3D &(mi->client_connect_defer_= state); + const struct client_connect_defer_state *ccs =3D &(mi->client_connect_= defer_state); enum client_connect_return ret =3D CC_RET_SKIPPED; ret =3D ccs_test_deferred_ret_file(mi); @@ -2568,7 +2568,7 @@ override_locked_username(struct multi_instance *mi) { struct tls_multi *multi =3D mi->context.c2.tls_multi; - struct options *options =3D &mi->context.options; + const struct options *options =3D &mi->context.options; struct tls_session *session =3D &multi->session[TM_ACTIVE]; if (!multi->locked_username) @@ -2987,7 +2987,7 @@ { #if defined(ENABLE_ASYNC_PUSH) bool was_unauthenticated =3D true; - struct key_state *ks =3D NULL; + const struct key_state *ks =3D NULL; if (mi->context.c2.tls_multi) { ks =3D &mi->context.c2.tls_multi->session[TM_ACTIVE].key[KS_PR= IMARY]; @@ -3104,7 +3104,7 @@ struct multi_instance *ex_mi =3D (struct multi_instance *)he->valu= e; struct tls_multi *m1 =3D mi->context.c2.tls_multi; - struct tls_multi *m2 =3D ex_mi->context.c2.tls_multi; + const struct tls_multi *m2 =3D ex_mi->context.c2.tls_multi; /* do not float if target address is taken by client with another = cert */ if (!cert_hash_compare(m1->locked_cert_hash_set, m2->locked_cert_h= ash_set)) @@ -3864,7 +3864,7 @@ static int management_callback_n_clients(void *arg) { - struct multi_context *m =3D (struct multi_context *)arg; + const struct multi_context *m =3D (struct multi_context *)arg; return m->n_clients; } diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sitnl.c index b3f8e2b..e6e72d0 100644 --- a/src/openvpn/networking_sitnl.c +++ b/src/openvpn/networking_sitnl.c @@ -462,7 +462,7 @@ struct rtattr *rta =3D RTM_RTA(r); size_t len =3D n->nlmsg_len - NLMSG_LENGTH(sizeof(*r)); unsigned int table, ifindex =3D 0; - void *gw =3D NULL; + const void *gw =3D NULL; /* filter-out non-zero dst prefixes */ if (res->default_only && r->rtm_dst_len !=3D 0) @@ -1179,7 +1179,7 @@ net_route_v4_add(openvpn_net_ctx_t *ctx, const in_addr_t *dst, int prefixl= en, const in_addr_t *gw, const char *iface, uint32_t table, int metric) { - in_addr_t *dst_ptr =3D NULL, *gw_ptr =3D NULL; + const in_addr_t *dst_ptr =3D NULL, *gw_ptr =3D NULL; in_addr_t dst_be =3D 0, gw_be =3D 0; char dst_str[INET_ADDRSTRLEN]; char gw_str[INET_ADDRSTRLEN]; @@ -1326,7 +1326,7 @@ #if defined(ENABLE_DCO) if (arg && (strcmp(type, OVPN_FAMILY_NAME) =3D=3D 0)) { - dco_context_t *dco =3D arg; + const dco_context_t *dco =3D arg; struct rtattr *data =3D SITNL_NEST(&req.n, sizeof(req), IFLA_INFO_= DATA); /* the netlink format is uint8_t for this and using something diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 53fb060..fd0d3fc 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -1877,7 +1877,7 @@ SHOW_INT(verify_hash_algo); SHOW_INT(verify_hash_depth); struct gc_arena gc =3D gc_new(); - struct verify_hash_list *hl =3D o->verify_hash; + const struct verify_hash_list *hl =3D o->verify_hash; int digest_len =3D (o->verify_hash_algo =3D=3D MD_SHA1) ? SHA_DIGEST_LENGTH : SHA= 256_DIGEST_LENGTH; while (hl) @@ -2333,7 +2333,7 @@ for (int i =3D 0; i < ce->local_list->len; i++) { - struct local_entry *le =3D ce->local_list->array[i]; + const struct local_entry *le =3D ce->local_list->array[i]; if (proto_is_net(le->proto) && string_defined_equal(le->local, ce-= >remote) && string_defined_equal(le->port, ce->remote_port)) @@ -3988,7 +3988,7 @@ { char *fullpath =3D string_alloc(file, NULL); /* POSIX dirname() implementation ma= y modify its arguments */ - char *dirpath =3D dirname(fullpath); + const char *dirpath =3D dirname(fullpath); if (platform_access(dirpath, mode | X_OK) !=3D 0) { @@ -4219,7 +4219,7 @@ ASSERT(options->connection_list); for (int i =3D 0; i < options->connection_list->len; ++i) { - struct connection_entry *ce =3D options->connection_list->array[i]; + const struct connection_entry *ce =3D options->connection_list->ar= ray[i]; errs |=3D check_file_access_inline(ce->tls_auth_file_inline, CHKAC= C_FILE | CHKACC_PRIVATE, ce->tls_auth_file, R_OK, "--tls-a= uth"); @@ -9091,7 +9091,7 @@ #ifdef ENABLE_PKCS11 else if (streq(p[0], "show-pkcs11-ids") && !p[3]) { - char *provider =3D p[1]; + const char *provider =3D p[1]; bool cert_private =3D (p[2] =3D=3D NULL ? false : (atoi_warn(p[2],= msglevel) !=3D 0)); =20 #ifdef DEFAULT_PKCS11_MODULE diff --git a/src/openvpn/options_parse.c b/src/openvpn/options_parse.c index a8c4aee..88ab4d2 100644 --- a/src/openvpn/options_parse.c +++ b/src/openvpn/options_parse.c @@ -268,7 +268,7 @@ while (in_src_get(is, line, sizeof(line))) { (*num_lines)++; - char *line_ptr =3D line; + const char *line_ptr =3D line; /* Remove leading spaces */ while (isspace(*line_ptr)) { diff --git a/src/openvpn/options_util.c b/src/openvpn/options_util.c index 47fe0bc..dc4d3ea 100644 --- a/src/openvpn/options_util.c +++ b/src/openvpn/options_util.c @@ -272,7 +272,7 @@ return true; } - struct pull_filter *f; + const struct pull_filter *f; for (f =3D o->pull_filter_list->head; f; f =3D f->next) { diff --git a/src/openvpn/pool.c b/src/openvpn/pool.c index 15004c0..97f59f3 100644 --- a/src/openvpn/pool.c +++ b/src/openvpn/pool.c @@ -63,7 +63,7 @@ for (i =3D 0; i < pool->size; ++i) { - struct ifconfig_pool_entry *ipe =3D &pool->list[i]; + const struct ifconfig_pool_entry *ipe =3D &pool->list[i]; if (!ipe->in_use) { /* diff --git a/src/openvpn/proxy.c b/src/openvpn/proxy.c index 9f3ec93..4de7615 100644 --- a/src/openvpn/proxy.c +++ b/src/openvpn/proxy.c @@ -703,7 +703,7 @@ #if PROXY_DIGEST_AUTH else if (p->auth_method =3D=3D HTTP_AUTH_DIGEST && !processed) { - char *pa =3D p->proxy_authenticate; + const char *pa =3D p->proxy_authenticate; const int method =3D p->auth_method; ASSERT(pa); diff --git a/src/openvpn/push.c b/src/openvpn/push.c index ae0f0e2..a030acd 100644 --- a/src/openvpn/push.c +++ b/src/openvpn/push.c @@ -271,8 +271,8 @@ } #ifdef ENABLE_MANAGEMENT struct tls_session *session =3D &c->c2.tls_multi->session[TM_ACTIVE]; - struct man_def_auth_context *mda =3D session->opt->mda_context; - struct env_set *es =3D session->opt->es; + const struct man_def_auth_context *mda =3D session->opt->mda_context; + const struct env_set *es =3D session->opt->es; unsigned int mda_key_id =3D get_primary_key(c->c2.tls_multi)->mda_key_= id; management_notify_client_cr_response(mda_key_id, mda, es, m); @@ -913,7 +913,7 @@ push_options(struct options *o, char **p, msglvl_t msglevel, struct gc_are= na *gc) { const char **argv =3D make_extended_arg_array(p, false, gc); - char *opt =3D print_argv(argv, gc, 0); + const char *opt =3D print_argv(argv, gc, 0); push_option(o, opt, msglevel); } @@ -1197,7 +1197,7 @@ /* parse route-ipv6 arguments */ if (get_ipv6_addr(p[1], &network, &netbits, D_ROUTE_DE= BUG)) { - struct iroute_ipv6 *ir; + const struct iroute_ipv6 *ir; /* does this route-ipv6 match an iroute-ipv6? */ for (ir =3D o->iroutes_ipv6; ir !=3D NULL; ir =3D = ir->next) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index ed77efe..3dca4ec 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -667,7 +667,7 @@ /* parse the routes from opt to rl */ { - struct route_option *ro; + const struct route_option *ro; for (ro =3D opt->routes; ro; ro =3D ro->next) { struct addrinfo *netlist =3D NULL; @@ -799,7 +799,7 @@ need_remote_ipv6_route =3D false; { - struct route_ipv6_option *ro6; + const struct route_ipv6_option *ro6; for (ro6 =3D opt6->routes_ipv6; ro6; ro6 =3D ro6->next) { struct route_ipv6 *r6; @@ -1187,7 +1187,7 @@ { if (rl6 && (rl6->iflags & RL_ROUTES_ADDED)) { - struct route_ipv6 *r6; + const struct route_ipv6 *r6; for (r6 =3D rl6->routes_ipv6; r6; r6 =3D r6->next) { delete_route_ipv6(r6, tt, es, ctx); @@ -1226,7 +1226,7 @@ void print_route_options(const struct route_option_list *rol, msglvl_t msglevel) { - struct route_option *ro; + const struct route_option *ro; if (rol->flags & RG_ENABLE) { msg(msglevel, " [redirect_default_gateway local=3D%d]", (rol->fla= gs & RG_LOCAL) !=3D 0); @@ -1335,7 +1335,7 @@ setenv_routes(struct env_set *es, const struct route_list *rl) { int i =3D 1; - struct route_ipv4 *r; + const struct route_ipv4 *r; for (r =3D rl->routes; r; r =3D r->next) { setenv_route(es, r, i++); @@ -1372,7 +1372,7 @@ setenv_routes_ipv6(struct env_set *es, const struct route_ipv6_list *rl6) { int i =3D 1; - struct route_ipv6 *r6; + const struct route_ipv6 *r6; for (r6 =3D rl6->routes_ipv6; r6; r6 =3D r6->next) { setenv_route_ipv6(es, r6, i++); @@ -2423,7 +2423,7 @@ */ if (rl && tt->did_ifconfig_setup) { - struct route_ipv4 *r; + const struct route_ipv4 *r; for (r =3D rl->routes, len =3D 0; r; r =3D r->next, ++len) { test_route_helper(&ret, &count, &good, &ambig, adapters, r= ->gateway); @@ -3110,7 +3110,8 @@ /* scan adapter list */ if (rgi->flags & RGI_ADDR_DEFINED) { - struct ifreq *ifr, *ifend; + struct ifreq *ifr; + const struct ifreq *ifend; in_addr_t addr, netmask; struct ifreq ifreq; struct ifconf ifc; diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index da6f870..332c46e 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -393,7 +393,7 @@ =20 for (int j =3D 0; j < ce->local_list->len; j++) { - struct local_entry *le =3D ce->local_list->array[j]; + const struct local_entry *le =3D ce->local_list->array[j]; if (!le->local) { @@ -926,12 +926,10 @@ * What is the correct way to deal with it? */ - struct addrinfo *cur; - ASSERT(local); - /* find the first addrinfo with correct ai_family */ + const struct addrinfo *cur; for (cur =3D local; cur; cur =3D cur->ai_next) { if (cur->ai_family =3D=3D ai_family) @@ -1514,7 +1512,7 @@ /* Socket is always bound on the first matching address, * For bound sockets with no remote addr this is the element of * the list */ - struct addrinfo *cur; + const struct addrinfo *cur; for (cur =3D sock->info.lsa->bind_local; cur; cur =3D cur->ai_next) { if (!ai_family || ai_family =3D=3D cur->ai_family) @@ -1645,7 +1643,7 @@ create_socket_dco_win(struct context *c, struct link_socket *sock, struct = signal_info *sig_info) { /* in P2P mode we must have remote resolved at this point */ - struct addrinfo *remoteaddr =3D sock->info.lsa->current_remote; + const struct addrinfo *remoteaddr =3D sock->info.lsa->current_remote; if ((c->options.mode =3D=3D MODE_POINT_TO_POINT) && (!remoteaddr)) { return; @@ -1930,7 +1928,7 @@ const struct link_socket_actual *from_addr) { struct gc_arena gc =3D gc_new(); - struct addrinfo *ai; + const struct addrinfo *ai; switch (from_addr->dest.addr.sa.sa_family) { diff --git a/src/openvpn/socket.h b/src/openvpn/socket.h index 6196af0..71a3595 100644 --- a/src/openvpn/socket.h +++ b/src/openvpn/socket.h @@ -762,7 +762,7 @@ { if (sock && ipbuf) { - struct openvpn_iphdr *iph =3D (struct openvpn_iphdr *)BPTR(ipbuf); + const struct openvpn_iphdr *iph =3D (struct openvpn_iphdr *)BPTR(i= pbuf); sock->ptos =3D iph->tos; sock->ptos_defined =3D true; } diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index d332359c..7f3b4dc 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -1478,7 +1478,7 @@ static bool generate_key_expansion(struct tls_multi *multi, struct key_state *ks, stru= ct tls_session *session) { - struct key_ctx_bi *key =3D &ks->crypto_options.key_ctx_bi; + const struct key_ctx_bi *key =3D &ks->crypto_options.key_ctx_bi; bool ret =3D false; struct key2 key2; @@ -1740,7 +1740,7 @@ static void flush_payload_buffer(struct key_state *ks) { - struct buffer *b; + const struct buffer *b; while ((b =3D buffer_list_peek(ks->paybuf))) { @@ -2719,7 +2719,7 @@ /* Outgoing Ciphertext to reliable buffer */ if (ks->state >=3D S_START) { - struct buffer *buf =3D reliable_get_buf_output_sequenced(ks->send_= reliable); + const struct buffer *buf =3D reliable_get_buf_output_sequenced(ks-= >send_reliable); if (buf) { if (!write_outgoing_tls_ciphertext(session, continue_tls_proce= ss)) @@ -2788,7 +2788,7 @@ { int opcode; - struct buffer *buf =3D reliable_send(ks->send_reliable, &opcode); + const struct buffer *buf =3D reliable_send(ks->send_reliable, &opc= ode); ASSERT(buf); struct buffer b =3D *buf; INCR_SENT; @@ -3151,7 +3151,7 @@ static void check_session_buf_not_used(struct buffer *to_link, struct tls_session *ses= sion) { - uint8_t *dataptr =3D to_link->data; + const uint8_t *dataptr =3D to_link->data; if (!dataptr) { return; @@ -3167,7 +3167,7 @@ for (int i =3D 0; i < KS_SIZE; i++) { - struct key_state *ks =3D &session->key[i]; + const struct key_state *ks =3D &session->key[i]; if (ks->state =3D=3D S_UNDEF) { continue; @@ -3232,7 +3232,7 @@ { struct tls_session *session =3D &multi->session[i]; struct key_state *ks =3D &session->key[KS_PRIMARY]; - struct key_state *ks_lame =3D &session->key[KS_LAME_DUCK]; + const struct key_state *ks_lame =3D &session->key[KS_LAME_DUCK]; /* set initial remote address. This triggers connecting with that * session. So we only do that if the TM_ACTIVE session is not @@ -3433,7 +3433,7 @@ for (int i =3D 0; i < KEY_SCAN_SIZE; ++i) { - struct key_state *ks =3D get_key_scan(multi, i); + const struct key_state *ks =3D get_key_scan(multi, i); if (ks->key_id !=3D key_id) { continue; @@ -3985,7 +3985,7 @@ void tls_prepend_opcode_v1(const struct tls_multi *multi, struct buffer *buf) { - struct key_state *ks =3D multi->save_ks; + const struct key_state *ks =3D multi->save_ks; msg(D_TLS_DEBUG, __func__); @@ -3999,7 +3999,7 @@ void tls_prepend_opcode_v2(const struct tls_multi *multi, struct buffer *buf) { - struct key_state *ks =3D multi->save_ks; + const struct key_state *ks =3D multi->save_ks; uint32_t peer; msg(D_TLS_DEBUG, __func__); diff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c index 8a0f7d2..9d408c0 100644 --- a/src/openvpn/ssl_mbedtls.c +++ b/src/openvpn/ssl_mbedtls.c @@ -301,7 +301,7 @@ void tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers) { - char *tmp_ciphers, *tmp_ciphers_orig, *token; + char *tmp_ciphers, *tmp_ciphers_orig; if (NULL =3D=3D ciphers) { @@ -320,7 +320,7 @@ int i =3D 0; tmp_ciphers_orig =3D tmp_ciphers =3D string_alloc(ciphers, NULL); - token =3D strtok(tmp_ciphers, ":"); + const char *token =3D strtok(tmp_ciphers, ":"); while (token) { ctx->allowed_ciphers[i] =3D mbedtls_ssl_get_ciphersuite_id(tls_tra= nslate_cipher_name(token)); @@ -744,7 +744,7 @@ static inline size_t external_key_len(void *vctx) { - struct external_context *const ctx =3D vctx; + const struct external_context *const ctx =3D vctx; return ctx->signature_length; } diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 0804d2d..e5b55a1 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -409,7 +409,7 @@ const char *subject, const struct x509_track *x509_tra= ck) { char envname[64]; - char *serial =3D NULL; + const char *serial =3D NULL; struct gc_arena gc =3D gc_new(); /* Save X509 fields in environment */ @@ -699,7 +699,7 @@ goto cleanup; } - struct verify_hash_list *current_hash =3D opt->verify_hash; + const struct verify_hash_list *current_hash =3D opt->verify_hash; while (current_hash) { @@ -1530,7 +1530,7 @@ verify_user_pass_management(struct tls_session *session, const struct user= _pass *up) { int retval =3D KMDA_ERROR; - struct key_state *ks =3D &session->key[KS_PRIMARY]; /* primary key */ + const struct key_state *ks =3D &session->key[KS_PRIMARY]; /* primary k= ey */ /* set username/password in private env space */ setenv_str(session->opt->es, "password", up->password); diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index f46802f..0103588 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -1735,7 +1735,7 @@ { u_int32_t type; struct iovec iv[2]; - struct ip *iph =3D (struct ip *)buf; + const struct ip *iph =3D (struct ip *)buf; if (iph->ip_v =3D=3D 6) { diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index 5ee65fb..1dc8e3b 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -889,7 +889,7 @@ if (es) { - struct env_item *e; + const struct env_item *e; char *ret; char *p; size_t nchars =3D 1; diff --git a/src/openvpnmsica/msica_arg.c b/src/openvpnmsica/msica_arg.c index a334710..d763d93 100644 --- a/src/openvpnmsica/msica_arg.c +++ b/src/openvpnmsica/msica_arg.c @@ -92,7 +92,7 @@ { /* Count required space. */ size_t size =3D 2 /*x + zero-terminator*/; - for (struct msica_arg *p =3D seq->head; p !=3D NULL; p =3D p->next) + for (const struct msica_arg *p =3D seq->head; p !=3D NULL; p =3D p->ne= xt) { size +=3D wcslen(p->val) + 1 /*space delimiter|zero-terminator*/; } @@ -119,7 +119,7 @@ /* Join. */ LPWSTR s =3D str + 1 /*x*/; - for (struct msica_arg *p =3D seq->head; p !=3D NULL; p =3D p->next) + for (const struct msica_arg *p =3D seq->head; p !=3D NULL; p =3D p->ne= xt) { /* Convert zero-terminator into space delimiter. */ s[0] =3D L' '; diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsic= a.c index d698c04..6a71801 100644 --- a/src/openvpnmsica/openvpnmsica.c +++ b/src/openvpnmsica/openvpnmsica.c @@ -196,7 +196,7 @@ /* Count adapters. */ size_t adapter_count =3D 0; - for (struct tap_adapter_node *pAdapter =3D pAdapterList; pAdapter; pAd= apter =3D pAdapter->pNext) + for (const struct tap_adapter_node *pAdapter =3D pAdapterList; pAdapte= r; pAdapter =3D pAdapter->pNext) { adapter_count++; } diff --git a/src/plugins/auth-pam/auth-pam.c b/src/plugins/auth-pam/auth-pa= m.c index 3b7bcc2..948b6af 100644 --- a/src/plugins/auth-pam/auth-pam.c +++ b/src/plugins/auth-pam/auth-pam.c @@ -526,7 +526,7 @@ openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, con= st char *argv[], const char *envp[]) { - struct auth_pam_context *context =3D (struct auth_pam_context *)handle; + const struct auth_pam_context *context =3D (struct auth_pam_context *)= handle; if (type =3D=3D OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY && context->foreg= round_fd >=3D 0) { diff --git a/src/tapctl/main.c b/src/tapctl/main.c index 6a4a240..6697d14 100644 --- a/src/tapctl/main.c +++ b/src/tapctl/main.c @@ -317,7 +317,7 @@ return NULL; } - struct tap_adapter_node *conflict =3D find_adapter_by_name(request= ed_name, adapter_list); + const struct tap_adapter_node *conflict =3D find_adapter_by_name(r= equested_name, adapter_list); if (conflict) { LPOLESTR adapter_id =3D NULL; diff --git a/tests/unit_tests/openvpn/test_buffer.c b/tests/unit_tests/open= vpn/test_buffer.c index 326de40..ce38bbe 100644 --- a/tests/unit_tests/openvpn/test_buffer.c +++ b/tests/unit_tests/openvpn/test_buffer.c @@ -88,7 +88,7 @@ int maxoutput =3D 0; unsigned int blocksize =3D 5; - char *separator =3D " "; + const char *separator =3D " "; output =3D format_hex_ex(input, input_size, maxoutput, blocksize, sepa= rator, &gc); assert_string_equal(output, "0100ff10ff 00f00f090a"); @@ -174,7 +174,7 @@ /* With a max length of 2, no aggregation should take place */ buffer_list_aggregate_separator(ctx->one_two_three, 2, testsep); assert_int_equal(ctx->one_two_three->size, 3); - struct buffer *buf =3D buffer_list_peek(ctx->one_two_three); + const struct buffer *buf =3D buffer_list_peek(ctx->one_two_three); assert_buf_equals_str(buf, teststr1); } @@ -189,7 +189,7 @@ */ buffer_list_aggregate_separator(ctx->one_two_three, strlen(expected) += 1, testsep); assert_int_equal(ctx->one_two_three->size, 2); - struct buffer *buf =3D buffer_list_peek(ctx->one_two_three); + const struct buffer *buf =3D buffer_list_peek(ctx->one_two_three); assert_buf_equals_str(buf, expected); } @@ -201,7 +201,7 @@ /* Aggregate all */ buffer_list_aggregate_separator(ctx->one_two_three, 1 << 16, testsep); assert_int_equal(ctx->one_two_three->size, 1); - struct buffer *buf =3D buffer_list_peek(ctx->one_two_three); + const struct buffer *buf =3D buffer_list_peek(ctx->one_two_three); assert_buf_equals_str(buf, teststr1 testsep teststr2 testsep teststr3 = testsep); } @@ -213,7 +213,7 @@ /* Aggregate all */ buffer_list_aggregate_separator(ctx->one_two_three, 1 << 16, testnosep= ); assert_int_equal(ctx->one_two_three->size, 1); - struct buffer *buf =3D buffer_list_peek(ctx->one_two_three); + const struct buffer *buf =3D buffer_list_peek(ctx->one_two_three); assert_buf_equals_str(buf, teststr1 teststr2 teststr3); } @@ -226,7 +226,7 @@ /* Aggregate all */ buffer_list_aggregate_separator(bl_zerolen, 1 << 16, testnosep); assert_int_equal(bl_zerolen->size, 1); - struct buffer *buf =3D buffer_list_peek(bl_zerolen); + const struct buffer *buf =3D buffer_list_peek(bl_zerolen); assert_buf_equals_str(buf, ""); } @@ -239,7 +239,7 @@ /* Aggregate all */ buffer_list_aggregate_separator(bl_emptybuffers, 1 << 16, testnosep); assert_int_equal(bl_emptybuffers->size, 1); - struct buffer *buf =3D buffer_list_peek(bl_emptybuffers); + const struct buffer *buf =3D buffer_list_peek(bl_emptybuffers); assert_int_equal(BLEN(buf), 0); } diff --git a/tests/unit_tests/openvpn/test_crypto.c b/tests/unit_tests/open= vpn/test_crypto.c index cb4eaa2..8393e1c 100644 --- a/tests/unit_tests/openvpn/test_crypto.c +++ b/tests/unit_tests/openvpn/test_crypto.c @@ -479,9 +479,9 @@ crypto_test_hkdf_expand_testa1(void **state) { /* RFC 5889 A.1 Test Case 1 */ - uint8_t prk[32] =3D { 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, = 0x0d, 0xdc, 0x3f, - 0x0d, 0xc4, 0x7b, 0xba, 0x63, 0x90, 0xb6, 0xc7, 0x= 3b, 0xb5, 0x0f, - 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0x= b3, 0xe5 }; + const uint8_t prk[32] =3D { 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, = 0xdf, 0x0d, 0xdc, 0x3f, + 0x0d, 0xc4, 0x7b, 0xba, 0x63, 0x90, 0xb6, 0x= c7, 0x3b, 0xb5, 0x0f, + 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0x= c2, 0xb3, 0xe5 }; uint8_t info[10] =3D { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,= 0xf8, 0xf9 }; @@ -500,9 +500,9 @@ crypto_test_hkdf_expand_testa2(void **state) { /* RFC 5889 A.2 Test Case 2 */ - uint8_t prk[32] =3D { 0x06, 0xa6, 0xb8, 0x8c, 0x58, 0x53, 0x36, 0x1a, = 0x06, 0x10, 0x4c, - 0x9c, 0xeb, 0x35, 0xb4, 0x5c, 0xef, 0x76, 0x00, 0x= 14, 0x90, 0x46, - 0x71, 0x01, 0x4a, 0x19, 0x3f, 0x40, 0xc1, 0x5f, 0x= c2, 0x44 }; + const uint8_t prk[32] =3D { 0x06, 0xa6, 0xb8, 0x8c, 0x58, 0x53, 0x36, = 0x1a, 0x06, 0x10, 0x4c, + 0x9c, 0xeb, 0x35, 0xb4, 0x5c, 0xef, 0x76, 0x= 00, 0x14, 0x90, 0x46, + 0x71, 0x01, 0x4a, 0x19, 0x3f, 0x40, 0xc1, 0x= 5f, 0xc2, 0x44 }; uint8_t info[80] =3D { 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,= 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0= xc4, 0xc5, 0xc6, 0xc7, @@ -531,11 +531,11 @@ crypto_test_hkdf_expand_testa3(void **state) { /* RFC 5889 A.3 Test Case 3 */ - uint8_t prk[32] =3D { 0x19, 0xef, 0x24, 0xa3, 0x2c, 0x71, 0x7b, 0x16, = 0x7f, 0x33, 0xa9, - 0x1d, 0x6f, 0x64, 0x8b, 0xdf, 0x96, 0x59, 0x67, 0x= 76, 0xaf, 0xdb, - 0x63, 0x77, 0xac, 0x43, 0x4c, 0x1c, 0x29, 0x3c, 0x= cb, 0x04 }; + const uint8_t prk[32] =3D { 0x19, 0xef, 0x24, 0xa3, 0x2c, 0x71, 0x7b, = 0x16, 0x7f, 0x33, 0xa9, + 0x1d, 0x6f, 0x64, 0x8b, 0xdf, 0x96, 0x59, 0x= 67, 0x76, 0xaf, 0xdb, + 0x63, 0x77, 0xac, 0x43, 0x4c, 0x1c, 0x29, 0x= 3c, 0xcb, 0x04 }; - uint8_t info[] =3D { 0 }; + const uint8_t info[] =3D { 0 }; int L =3D 42; uint8_t okm[42] =3D { 0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, = 0x71, 0x5f, 0x80, @@ -555,9 +555,9 @@ /* tests the HDKF with a label/okm that OpenVPN itself uses in OpenSSL= 3 * HDKF unit test*/ - uint8_t prk[32] =3D { 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, = 0x0d, 0xdc, 0x3f, - 0x0d, 0xc4, 0x7b, 0xba, 0x63, 0x90, 0xb6, 0xc7, 0x= 3b, 0xb5, 0x0f, - 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0x= b3, 0xe5 }; + const uint8_t prk[32] =3D { 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, = 0xdf, 0x0d, 0xdc, 0x3f, + 0x0d, 0xc4, 0x7b, 0xba, 0x63, 0x90, 0xb6, 0x= c7, 0x3b, 0xb5, 0x0f, + 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0x= c2, 0xb3, 0xe5 }; uint8_t info[18] =3D { 0x00, 0x1b, 0x0e, 0x6f, 0x76, 0x70, 0x6e, 0x20,= 0x75, 0x6e, 0x69, 0x74, 0x20, 0x74, 0x65, 0x73, 0x74, 0= x00 }; @@ -677,7 +677,7 @@ static int crypto_test_epoch_setup(void **state) { - uint16_t *num_future_keys =3D (uint16_t *)*state; + const uint16_t *num_future_keys =3D (uint16_t *)*state; struct epoch_test_state *data =3D calloc(1, sizeof(struct epoch_test_s= tate)); data->gc =3D gc_new(); diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_tests/o= penvpn/test_cryptoapi.c index 508afc9..37bbe92 100644 --- a/tests/unit_tests/openvpn/test_cryptoapi.c +++ b/tests/unit_tests/openvpn/test_cryptoapi.c @@ -233,7 +233,7 @@ const CERT_CONTEXT *ctx =3D NULL; while ((ctx =3D CertEnumCertificatesInStore(user_store, ctx))) { - char *friendly_name =3D get_cert_name(ctx, &gc); + const char *friendly_name =3D get_cert_name(ctx, &gc); if (!lookup_cert(friendly_name)) /* not our cert */ { continue; @@ -310,7 +310,7 @@ */ assert_non_null(ctx); - char *friendly_name =3D get_cert_name(ctx, &gc); + const char *friendly_name =3D get_cert_name(ctx, &gc); struct test_cert *found =3D lookup_cert(friendly_name); assert_non_null(found); assert_string_equal(found->cname, c->cname); @@ -343,7 +343,7 @@ */ assert_non_null(ctx); - char *friendly_name =3D get_cert_name(ctx, &gc); + const char *friendly_name =3D get_cert_name(ctx, &gc); struct test_cert *found =3D lookup_cert(friendly_name); assert_non_null(found); assert_string_equal(found->issuer, c->issuer); diff --git a/tests/unit_tests/openvpn/test_misc.c b/tests/unit_tests/openvp= n/test_misc.c index a9ae33f..4a055e7 100644 --- a/tests/unit_tests/openvpn/test_misc.c +++ b/tests/unit_tests/openvpn/test_misc.c @@ -301,7 +301,7 @@ { for (ptr_type i =3D 1; i <=3D 16; ++i) { - struct hash_element *item =3D hash_lookup_by_value(nhash, (voi= d *)i); + const struct hash_element *item =3D hash_lookup_by_value(nhash= , (void *)i); hash_remove_by_value(nhash, (void *)i); /* check item got removed if it was present before */ if (item) diff --git a/tests/unit_tests/openvpn/test_pkt.c b/tests/unit_tests/openvpn= /test_pkt.c index cad2ce0..df9fed7 100644 --- a/tests/unit_tests/openvpn/test_pkt.c +++ b/tests/unit_tests/openvpn/test_pkt.c @@ -567,7 +567,7 @@ ASSERT(md_valid("SHA256")); hmac_ctx_t *hmac_ctx =3D hmac_ctx_new(); - uint8_t key[SHA256_DIGEST_LENGTH] =3D { 1, 2, 3, 0 }; + const uint8_t key[SHA256_DIGEST_LENGTH] =3D { 1, 2, 3, 0 }; hmac_ctx_init(hmac_ctx, key, "SHA256"); return hmac_ctx; diff --git a/tests/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn= /test_ssl.c index c40845a..9f5d34a 100644 --- a/tests/unit_tests/openvpn/test_ssl.c +++ b/tests/unit_tests/openvpn/test_ssl.c @@ -683,7 +683,7 @@ openvpn_encrypt(&buf, encrypt_workspace, &co); /* separate buffer in authenticated data and encrypted data */ - uint8_t *ad_start =3D BPTR(&buf); + const uint8_t *ad_start =3D BPTR(&buf); buf_advance(&buf, 4); if (epoch) diff --git a/tests/unit_tests/plugins/auth-pam/test_search_and_replace.c b/= tests/unit_tests/plugins/auth-pam/test_search_and_replace.c index a861bfd..89f0642 100644 --- a/tests/unit_tests/plugins/auth-pam/test_search_and_replace.c +++ b/tests/unit_tests/plugins/auth-pam/test_search_and_replace.c @@ -12,7 +12,7 @@ static void pass_any_null_param__returns_null(void **state) { - char DUMMY[] =3D "DUMMY"; + const char DUMMY[] =3D "DUMMY"; assert_null(searchandreplace(NULL, DUMMY, DUMMY)); assert_null(searchandreplace(DUMMY, NULL, DUMMY)); @@ -22,8 +22,8 @@ static void pass_any_empty_string__returns_null(void **state) { - char DUMMY[] =3D "DUMMY"; - char EMPTY[] =3D ""; + const char DUMMY[] =3D "DUMMY"; + const char EMPTY[] =3D ""; assert_null(searchandreplace(EMPTY, DUMMY, DUMMY)); assert_null(searchandreplace(DUMMY, EMPTY, DUMMY)); -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1661?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I2b71dae37ebe63c26a66761f877b25d326ed140f Gerrit-Change-Number: 1661 Gerrit-PatchSet: 3 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --BfFWfMPAScY= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld uploaded patch set #3 to this change.

<= p>View C= hange

Remove instances of constVariable/constVariableP=
ointer cppcheck warnings

Of varied usefulness, but easier to just ad= dress all of
them.

Also change vpn_* parameters of dco_new_peer t= o const since
that is required by one of the changes and it works (and w= ould
happen anyway when doing constParameterPointer).

Change-Id: = I2b71dae37ebe63c26a66761f877b25d326ed140f
Signed-off-by: Frank Lichtenhe= ld <frank@...2641...>
---
M dev-tools/cppcheck-suppression
M= sample/sample-plugins/defer/multi-auth.c
M sample/sample-plugins/log/lo= g.c
M sample/sample-plugins/log/log_v3.c
M sample/sample-plugins/simp= le/simple.c
M src/openvpn/argv.c
M src/openvpn/auth_token.c
M src/= openvpn/base64.c
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M s= rc/openvpn/comp-lz4.c
M src/openvpn/crypto.c
M src/openvpn/crypto_epo= ch.c
M src/openvpn/cryptoapi.c
M src/openvpn/dco.c
M src/openvpn/d= co_freebsd.c
M src/openvpn/dco_internal.h
M src/openvpn/dco_linux.cM src/openvpn/dco_win.c
M src/openvpn/dns.c
M src/openvpn/forward.c=
M src/openvpn/init.c
M src/openvpn/list.c
M src/openvpn/manage.c<= br>M src/openvpn/misc.c
M src/openvpn/mss.c
M src/openvpn/mtcp.c
M= src/openvpn/mudp.c
M src/openvpn/multi.c
M src/openvpn/networking_si= tnl.c
M src/openvpn/options.c
M src/openvpn/options_parse.c
M src/= openvpn/options_util.c
M src/openvpn/pool.c
M src/openvpn/proxy.c
= M src/openvpn/push.c
M src/openvpn/route.c
M src/openvpn/socket.c
= M src/openvpn/socket.h
M src/openvpn/ssl.c
M src/openvpn/ssl_mbedtls.= c
M src/openvpn/ssl_verify.c
M src/openvpn/tun.c
M src/openvpn/win= 32.c
M src/openvpnmsica/msica_arg.c
M src/openvpnmsica/openvpnmsica.c=
M src/plugins/auth-pam/auth-pam.c
M src/tapctl/main.c
M tests/uni= t_tests/openvpn/test_buffer.c
M tests/unit_tests/openvpn/test_crypto.cM tests/unit_tests/openvpn/test_cryptoapi.c
M tests/unit_tests/openvpn= /test_misc.c
M tests/unit_tests/openvpn/test_pkt.c
M tests/unit_tests= /openvpn/test_ssl.c
M tests/unit_tests/plugins/auth-pam/test_search_and_= replace.c
55 files changed, 155 insertions(+), 156 deletions(-)

<= /pre>
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/cha=
nges/61/1661/3
diff --git a/dev-tools/cppcheck-suppression b/dev-to=
ols/cppcheck-suppression
index c9d4714..bb260c9 100644
--- a/dev-tools/cppcheck-suppression
+++ b/dev-= tools/cppcheck-suppression
@@ -3,8 +3,6 @@
= constParameter
constParameterCallback
co= nstParameterPointer
-co= nstVariable
-constVaria= blePointer
variableScope
# We have a lot = of library includes, not all of them are really required,
= # so ignore them
diff --git a/sample/sample-plugins/defer/m= ulti-auth.c b/sample/sample-plugins/defer/multi-auth.c
inde= x f6bbf44..33fbe61 100644
--- a/sample/sample-plugins/defer= /multi-auth.c
+++ b/sample/sample-plugins/defer/multi-auth.= c
@@ -399,7 +399,7 @@
OPENVPN_EXPORT void = *
openvpn_plugin_client_constructor_v1(openvpn_plugin_hand= le_t handle)
{
- struct plugin_context *context =3D (struct plugin_context *)h= andle;
+ const str= uct plugin_context *context =3D (struct plugin_context *)handle;
= plog(context, PLOG_NOTE, "FUNC: openvpn_plugin_client_const= ructor_v1");
return calloc(1, sizeof(struct plugi= n_per_client_context));
}
@@ -407,7 +407,7= @@
OPENVPN_EXPORT void
openvpn_plugin_cl= ient_destructor_v1(openvpn_plugin_handle_t handle, void *per_client_context= )
{
- = struct plugin_context *context =3D (struct plugin_context *)handle;
+ const struct plugin_= context *context =3D (struct plugin_context *)handle;
= plog(context, PLOG_NOTE, "FUNC: openvpn_plugin_client_destructor_v1&qu= ot;);
free(per_client_context);
}
diff --git a/sample/sample-plugins/log/log.c b/sample/sample-p= lugins/log/log.c
index 330e3e0..76350ee 100644
--- a/sample/sample-plugins/log/log.c

+++ b/sample/samp= le-plugins/log/log.c
@@ -173,7 +173,7 @@
o= penvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, const= char *argv[],
const char *envp[])<= /span>
{
- = struct plugin_context *context =3D (struct plugin_context *)handle;=
+ const struct plugin_co= ntext *context =3D (struct plugin_context *)handle;

show(type, argv, envp);

d= iff --git a/sample/sample-plugins/log/log_v3.c b/sample/sample-plugins/log/= log_v3.c
index d2d44c7..09c6735 100644
--- = a/sample/sample-plugins/log/log_v3.c
+++ b/sample/sample-pl= ugins/log/log_v3.c
@@ -245,7 +245,7 @@
ope= nvpn_plugin_func_v3(const int version, struct openvpn_plugin_args_func_in c= onst *args,
struct openvpn_plugin_a= rgs_func_return *retptr)
{
- struct plugin_context *context =3D (struct plugin= _context *)args->handle;
+ const struct plugin_context *context =3D (struct plugin_context= *)args->handle;

printf("\no= penvpn_plugin_func_v3() :::::>> ");
show(ar= gs->type, args->argv, args->envp);
diff --git a/sa= mple/sample-plugins/simple/simple.c b/sample/sample-plugins/simple/simple.c=
index 687a633..3182be0 100644
--- a/sample= /sample-plugins/simple/simple.c
+++ b/sample/sample-plugins= /simple/simple.c
@@ -104,7 +104,7 @@
openv= pn_plugin_func_v1(openvpn_plugin_handle_t handle, const int type, const cha= r *argv[],
const char *envp[])
{
- str= uct plugin_context *context =3D (struct plugin_context *)handle;
= + const struct plugin_contex= t *context =3D (struct plugin_context *)handle;
/* get username/password from envp string array */
const char *username =3D get_env("username", envp);
diff --git a/src/openvpn/argv.c b/src/openvpn/argv.c
= index 6a5d92e..028671d 100644
--- a/src/openvpn/argv.= c
+++ b/src/openvpn/argv.c
@@ -359,7 +359,7= @@
*
*/
s= ize_t argc =3D argres->argc;
- char *f =3D argv_prep_format(format, delim, &argc, &a= rgres->gc);
+ c= onst char *f =3D argv_prep_format(format, delim, &argc, &argres->= ;gc);
if (f =3D=3D NULL)
{=
goto out;
diff --git a/src/openvpn/auth_= token.c b/src/openvpn/auth_token.c
index d8ca125..0cfcd2d 1= 00644
--- a/src/openvpn/auth_token.c
+++ b/= src/openvpn/auth_token.c
@@ -217,7 +217,7 @@
* a new token with the empty username since we do not want to loose=

* the information that the username cannot be truste= d
*/
- struct key_state *ks =3D &multi->session[TM_ACTIVE].key[KS_= PRIMARY];
+ const = struct key_state *ks =3D &multi->session[TM_ACTIVE].key[KS_PRIMARY];=
if (ks->auth_token_state_flags & AUTH_TOKEN_VA= LID_EMPTYUSER)
{
hmac_ctx_upd= ate(ctx, (const uint8_t *)"", 0);
diff --git a/sr= c/openvpn/base64.c b/src/openvpn/base64.c
index 7af8976..57= 52844 100644
--- a/src/openvpn/base64.c
+++= b/src/openvpn/base64.c
@@ -161,7 +161,7 @@
{

const char *p;
unsigned char = *q;
- unsigned char = *e =3D NULL;
+ con= st unsigned char *e =3D NULL;

q =3D = data;
if (size >=3D 0)
diff --git a= /src/openvpn/buffer.c b/src/openvpn/buffer.c
index ee50dc5.= .131e1d6 100644
--- a/src/openvpn/buffer.c
= +++ b/src/openvpn/buffer.c
@@ -536,7 +536,7 @@
void

buf_null_terminate(struct buffer *buf) {
- char *la= st =3D (char *)BLAST(buf);
+ const char *last =3D (char *)BLAST(buf);
if= (last && *last =3D=3D '\0') /* already terminated? */
{
return;
@@ -559= ,7 +559,7 @@
{
while (true) {
- = char *last =3D (char *)BLAST(buf);
+ const char *last =3D (char *)BLAST(buf);
<= span> if (!last)

{
= break;
diff --git a/src/openvpn/buffer.h b/src/openvp= n/buffer.h
index b4e65ef..6a751ad 100644
--= - a/src/openvpn/buffer.h
+++ b/src/openvpn/buffer.h<= br>@@ -712,7 +712,7 @@
static inline bool
= buf_copy_n(struct buffer *dest, struct buffer *src, int n) {
- uint8_t = *cp =3D buf_read_alloc(src, n);
+ const uint8_t *cp =3D buf_read_alloc(src, n);
if (!cp)

{
return fal= se;
@@ -764,7 +764,7 @@
static inline bool=
buf_read(struct buffer *src, void *dest, int size)=
{
- uint8= _t *cp =3D buf_read_alloc(src, size);
+ const uint8_t *cp =3D buf_read_alloc(src, size);
if (!cp)
{
r= eturn false;
diff --git a/src/openvpn/comp-lz4.c b/src/open= vpn/comp-lz4.c
index 45f138c..48797b0 100644
--- a/src/openvpn/comp-lz4.c

+++ b/src/openvpn/comp-lz4.c=
@@ -164,7 +164,7 @@
ASSERT(buf_init(&= amp;work, frame->buf.headroom));

= /* do unframing/swap (assumes buf->len > 0) */
- uint8_t *head =3D BPTR(buf);
= + const uint8_t *head =3D BP= TR(buf);
c =3D *head;

/* Not compressed */

diff --git a/src/openvpn/crypto= .c b/src/openvpn/crypto.c
index df9b905..a9a33c0 100644
--- a/src/openvpn/crypto.c
+++ b/src/openvpn/c= rypto.c
@@ -1210,7 +1210,7 @@

<= span> /* init implicit IV */

{
- cipher_ctx_t *cipher =3D co->k= ey_ctx_bi.encrypt.cipher;
+ const cipher_ctx_t *cipher =3D co->key_ctx_bi.encrypt.ciph= er;
if (cipher_ctx_mode_aead(cipher))
{
ASSERT(cipher_ctx_iv_length(cip= her) <=3D OPENVPN_MAX_IV_LENGTH);
@@ -1919,7 +1919,7 @@<= /span>
const char *seed =3D "tls1-prf-test";=
const char *secret =3D "tls1-prf-test-secret";
uint8_t out[8];
- uint8_t expected_out[] =3D { 'q', 'D', 0xfe= , '%', '@', 's', 'u', 0x95 };
+ const uint8_t expected_out[] = =3D { 'q', 'D', 0xfe, '%', '@', 's'= , 'u', 0x95 };


int ret =3D s= sl_tls1_PRF((uint8_t *)seed, strlen(seed), (uint8_t *)secret,
strlen(secret), out, sizeof(out));
diff --git a/src/openvpn/crypto_epoch.c b/src/openvpn/crypto_epoch.c=
index 54225bf..3812435 100644
--- a/src/op= envpn/crypto_epoch.c
+++ b/src/openvpn/crypto_epoch.c
@@ -213,7 +213,7 @@
*
= * The last generated key might have been moved to the decrypt key already= .
*/
- struct key_ctx *highest_future_key =3D
+ const struct key_ctx *highest_future_key = =3D
&co->epoch_data_keys_future[co->epoc= h_data_keys_future_count - 1];

ASSER= T(co->epoch_key_recv.epoch =3D=3D 1 || highest_future_key->epoch =3D= =3D co->epoch_key_recv.epoch
diff --git a/src/openvpn/cr= yptoapi.c b/src/openvpn/cryptoapi.c
index e17936a..543a1b3 = 100644
--- a/src/openvpn/cryptoapi.c
+++ b/= src/openvpn/cryptoapi.c
@@ -223,7 +223,6 @@
const CERT_INFO *info =3D cert_ctx->pCertInfo;

= const CERT_EXTENSION *ext;
DWORD cbext;
- void *pvext;
= struct gc_arena gc =3D gc_new();
const WCHAR *tmpl= _name =3D wide_string(cert_prop, &gc);

@@ -231,7 +230,7 @@
ext =3D CertFindExtension(szOID_= CERTIFICATE_TEMPLATE, info->cExtension, info->rgExtension); if (ext)
{
- pvext =3D decode_object(&gc, X509_CERTIFI= CATE_TEMPLATE, &ext->Value, 0, &cbext);
+ const void *pvext =3D decode_object(= &gc, X509_CERTIFICATE_TEMPLATE, &ext->Value, 0, &cbext);
if (pvext && cbext >=3D sizeof(CERT_TEMPLA= TE_EXT))
{
const CERT= _TEMPLATE_EXT *cte =3D (const CERT_TEMPLATE_EXT *)pvext;
di= ff --git a/src/openvpn/dco.c b/src/openvpn/dco.c
index f5b7= 081..69ce1d7 100644
--- a/src/openvpn/dco.c
+++ b/src/openvpn/dco.c

@@ -109,7 +109,7 @@
for (int i =3D 0; i < KEY_SCAN_SIZE; ++i)
{<= /span>
struct key_state *ks =3D get_key_scan(multi, i);
- struct key_ctx_= bi *key =3D &ks->crypto_options.key_ctx_bi;
+ const struct key_ctx_bi *key =3D &am= p;ks->crypto_options.key_ctx_bi;

= if (ks =3D=3D primary)
{
@@ -5= 60,7 +560,7 @@
struct sockaddr_sto= rage *local)
{
#if ENABLE_IP_PKTINFO

- struct context *c =3D = &mi->context;
= + const struct context *c =3D &mi->context;

if (!proto_is_udp(c->c2.link_sockets[0]->info.proto= )
|| !(c->options.sockflags & SF_USE_IP_PKT= INFO))
@@ -608,7 +608,7 @@
int
<= span> dco_multi_add_new_peer(struct multi_context *m, struct multi_instance= *mi)

{
+ const struct context *c =3D &mi->c= ontext;

int peer_id =3D c->c2.tls= _multi->peer_id;
struct sockaddr *remoteaddr, *loca= laddr =3D NULL;
@@ -629,14 +629,14 @@

/* In server mode we need to fetch the remote addresses f= rom the push config */
struct in_addr vpn_ip4 =3D { 0 = };
- struct in_addr = *vpn_addr4 =3D NULL;
= + const struct in_addr *vpn_addr4 =3D NULL;
if (c-&= gt;c2.push_ifconfig_defined)
{
= vpn_ip4.s_addr =3D htonl(c->c2.push_ifconfig_local);
= vpn_addr4 =3D &vpn_ip4;
}
=
- struct in6_addr = *vpn_addr6 =3D NULL;
= + const struct in6_addr *vpn_addr6 =3D NULL;
if (c-= >c2.push_ifconfig_ipv6_defined)
{
= vpn_addr6 =3D &c->c2.push_ifconfig_ipv6_local;
@@ -685,7 +685,7 @@

}
#endif

- struc= t context *c =3D &mi->context;
+ const struct context *c =3D &mi->context;

if (addrtype =3D=3D MR_ADDR_IPV6)
{
#if defined(_WIN32)
@@ -733,7 +733,7 @@
}
ASSERT(TUNNEL_TYPE(mi->context.= c1.tuntap) =3D=3D DEV_TYPE_TUN);

- struct context *c =3D &mi->context;=
+ const struct co= ntext *c =3D &mi->context;

if= (mi->context.c2.push_ifconfig_defined)
{diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c
index eaca86b..d933aaf 100644
--- a/src/open= vpn/dco_freebsd.c
+++ b/src/openvpn/dco_freebsd.c@@ -134,7 +134,8 @@

int dco_new_peer(dco_context_t *dco, unsigned int peerid, int sd, struc= t sockaddr *localaddr,
= - struct sockaddr *remoteaddr, struct in_addr *vpn_ipv4, struct= in6_addr *vpn_ipv6)
= + struct sockaddr *remoteaddr, const struct in_addr *vpn_ipv4,<= /span>
+ const s= truct in6_addr *vpn_ipv6)
{
struct if= drv drv;
nvlist_t *nvl, *local_nvl, *remote_nvl;
diff --git a/src/openvpn/dco_internal.h b/src/openvpn/dco_intern= al.h
index da07780..fcf8aca 100644
--- a/sr= c/openvpn/dco_internal.h
+++ b/src/openvpn/dco_internal.h
@@ -60,7 +60,7 @@
*/

int dco_new_peer(dco_context_t *dco, unsigned int peerid, soc= ket_descriptor_t sd, struct sockaddr *localaddr,
- struct sockaddr *remoteaddr, st= ruct in_addr *vpn_ipv4, struct in6_addr *vpn_ipv6);
+ struct sockaddr *remotea= ddr, const struct in_addr *vpn_ipv4, const struct in6_addr *vpn_ipv6);

int dco_del_peer(dco_context_t *dco, unsigne= d int peerid);

diff --git a/src/openvpn/d= co_linux.c b/src/openvpn/dco_linux.c
index 40746bd..56f6259= 100644
--- a/src/openvpn/dco_linux.c
+++ b= /src/openvpn/dco_linux.c
@@ -222,7 +222,8 @@

int
dco_new_peer(dco_context_t *dco, = unsigned int peerid, int sd, struct sockaddr *localaddr,
- struct sockaddr *remoteaddr= , struct in_addr *vpn_ipv4, struct in6_addr *vpn_ipv6)
+ struct sockaddr *remoteaddr= , const struct in_addr *vpn_ipv4,
+ const struct in6_addr *vpn_ipv6)
{

struct gc_arena gc =3D gc_new();
= const char *remotestr =3D "[undefined]";
@@ -= 697,7 +698,7 @@
{
dco_context_t *dco = =3D arg;
struct nlattr *tb[CTRL_ATTR_MAX + 1];<= br>- struct genlmsghdr *gnlh = =3D nlmsg_data(nlmsg_hdr(msg));
+ const struct genlmsghdr *gnlh =3D nlmsg_data(nlmsg_hdr(msg)= );

nla_parse(tb, CTRL_ATTR_MAX, genl= msg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), NULL);

@@ -706,7 +707,7 @@
return NL_SKIP;=
}

- struct nlattr *mcgrp;
+ const struct nlattr *mcgrp;
= int rem_mcgrp;
nla_for_each_nested(mcgrp, tb[CTRL_= ATTR_MCAST_GROUPS], rem_mcgrp)
{
diff = --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c
index= 2e26f2a..0d375d8 100644
--- a/src/openvpn/dco_win.c=
+++ b/src/openvpn/dco_win.c
@@ -285,8 +285,8 @@
msg(D_DCO_DEBUG, "%s", __func__);
<= span>

int ai_family =3D sock->info.lsa->bind_lo= cal->ai_family;
- = struct addrinfo *local =3D sock->info.lsa->bind_local;
- struct addrinfo *cur =3D NULL;<= /span>
+ const struct add= rinfo *local =3D sock->info.lsa->bind_local;
+ const struct addrinfo *cur =3D NULL;


for (cur =3D local; cur; cur =3D cur-&g= t;ai_next)
{
@@ -334,7 +334,7 @@
struct addrinfo *remoteaddr =3D sock->info.lsa->curre= nt_remote;

struct sockaddr *local = =3D NULL;
- struct s= ockaddr *remote =3D remoteaddr->ai_addr;
+ const struct sockaddr *remote =3D remoteaddr-&g= t;ai_addr;

if (remoteaddr->ai_pro= tocol =3D=3D IPPROTO_TCP || remoteaddr->ai_socktype =3D=3D SOCK_STREAM)<= /span>
{
@@ -348,7 +348,7 @@
= if (sock->bind_local)
{
= /* Use first local address with correct address family */
- struct addrinfo *bind =3D so= ck->info.lsa->bind_local;

+ const struct addrinfo *bind =3D sock->info.lsa->b= ind_local;
while (bind && !local) {
if (bind->ai_family =3D= =3D remote->sa_family)
@@ -415,8 +415,9 @@
}


int
-dco_new_peer(dco_context_t *dco, unsigned int peerid= , socket_descriptor_t sd, struct sockaddr *localaddr,
- struct sockaddr *remoteaddr, s= truct in_addr *vpn_ipv4, struct in6_addr *vpn_ipv6)
+dco_new_peer(dco_context_t *dco, unsigned= int peerid, socket_descriptor_t sd,
+ struct sockaddr *localaddr, struct sockaddr *= remoteaddr,
+ = const struct in_addr *vpn_ipv4, const struct in6_addr *vpn_ipv6)
{
msg(D_DCO_DEBUG, "%s: peer-id %d, f= d " SOCKET_PRINTF, __func__, peerid, sd);

= diff --git a/src/openvpn/dns.c b/src/openvpn/dns.c
in= dex 954ed52..1bbb34e 100644
--- a/src/openvpn/dns.c<= br>+++ b/src/openvpn/dns.c
@@ -132,7 +132,7 @@=
}
else
{- struct sockaddr_in6 *si= n6 =3D (struct sockaddr_in6 *)ai->ai_addr;
+ const struct sockaddr_in6 *sin6 =3D (stru= ct sockaddr_in6 *)ai->ai_addr;
server->addr[= server->addr_count].in.a6 =3D sin6->sin6_addr;
}=

@@ -156,7 +156,7 @@
= /* Append all domains to the end of the list */
while= (*domains)
{
- char *domain =3D *domains++;
+ const char *domain =3D *domains++;

if (!validate_domain(domain))
= {
return false;
@@ -699,7 += 699,7 @@
run_up_down_command(bool up, struct options *o, c= onst struct tuntap *tt,
struct dns_upd= own_runner_info *updown_runner)
{
- struct dns_options *dns =3D &o->dns= _options;
+ const = struct dns_options *dns =3D &o->dns_options;
if= (!dns->updown || (o->up_script && !dns_updown_user_set(dns) = && !dns_updown_forced(dns)))
{
return;
@@ -864,7 +864,7 @@
= }
#ifdef _WIN32
/* Don't use iser= vice in DHCP mode */
- = struct tuntap_options *tto =3D &o->tuntap_options;
+ const struct tuntap_options *t= to =3D &o->tuntap_options;
if (tto->ip_win32= _type =3D=3D IPW32_SET_DHCP_MASQ || tto->ip_win32_type =3D=3D IPW32_SET_= ADAPTIVE)
{
return;diff --git a/src/openvpn/forward.c b/src/openvpn/forward.cindex 53eab4d..a4747ed 100644
--- a/src/openvpn/forw= ard.c
+++ b/src/openvpn/forward.c
@@ -1215,= 7 +1215,7 @@
{
if (float_sa->sa_fa= mily =3D=3D AF_INET)
{
- struct sockaddr_in *float4 =3D (struct sockad= dr_in *)float_sa;
+ = const struct sockaddr_in *float4 =3D (struct sockaddr_in *)float_sa;<= /span>
/* DCO treats IPv4-mapped IPv6 addresses as pure I= Pv4. However, on a
* dual-stack socket, we need t= o preserve the mapping otherwise openvpn
* will n= ot be able to find the peer by its transport address.
@@ -1= 238,7 +1238,7 @@
}
else {
- = struct sockaddr_in6 *float6 =3D (struct sockaddr_in6 *)float_sa;
= + const struct sockaddr_= in6 *float6 =3D (struct sockaddr_in6 *)float_sa;
m= emcpy(&out_osaddr->addr.in6, float6, sizeof(struct sockaddr_in6));
}
}
@@ -1369,7 +1369,7= @@
}

struct op= envpn_sockaddr *link_addr =3D &c->c2.to_link_addr->dest;- struct link_socket_info *l= si =3D get_link_socket_info(c);
+ const struct link_socket_info *lsi =3D get_link_socket_info= (c);

int ip_hdr_offset =3D 0;=
int tun_ip_ver =3D get_tun_ip_ver(TUNNEL_TYPE(c->c1.tunta= p), buf, &ip_hdr_offset);
@@ -2241,7 +2241,7 @@<= br>
if (e->arg >=3D MULTI= _N)
{
- struct event_arg *ev_arg =3D (= struct event_arg *)e->arg;
+ const struct event_arg *ev_arg =3D (struc= t event_arg *)e->arg;
if (ev_ar= g->type !=3D EVENT_ARG_LINK_SOCKET)
= {
c->c2.event_set_stat= us =3D ES_ERROR;
diff --git a/src/openvpn/init.c b/src/open= vpn/init.c
index caaa769..0861cb5 100644
--= - a/src/openvpn/init.c
+++ b/src/openvpn/init.c
<= span>@@ -319,8 +319,8 @@

management_callback_remote_entry_= count(void *arg)
{
ASSERT(arg);

- struct context *c =3D (= struct context *)arg;
-= struct connection_list *l =3D c->options.connection_list;
= + const struct context *c = =3D (struct context *)arg;
+ const struct connection_list *l =3D c->options.connection_lis= t;

return l->len;
}
@@ -342,7 +342,7 @@

= if (index < l->len)
{
- struct connection_entry *ce =3D l-&= gt;array[index];
+ = const struct connection_entry *ce =3D l->array[index];
const char *proto =3D proto2ascii(ce->proto, ce->af, fal= se);
const char *status =3D (ce->flags & CE= _DISABLED) ? "disabled" : "enabled";
<= /span>
@@ -525,7 +525,7 @@
{
= struct connection_list *l =3D c->options.connection_list;
bool ce_defined;

+ const struct connection_entry *ce;
= int n_cycles =3D 0;

do
@@ -1581,10 +1581,10 @@
/* Tell management interfa= ce that we initialized */
if (management)
{
- in_= addr_t *tun_local =3D NULL;
- struct in6_addr *tun_local6 =3D NULL;
+ const in_addr_t *tun_local =3D NU= LL;
+ const st= ruct in6_addr *tun_local6 =3D NULL;
struct openvpn= _sockaddr local, remote;
+ const struct link_socket_actual *actual;<= /span>
socklen_t sa_len =3D sizeof(local);
const char *detail =3D "SUCCESS";

= if (flags & ISC_ERRORS)
@@ -4302,7 +4302,7 @@
/* On some newer Android handsets, changing to a different= network
* often does not trigger a TCP reset but con= tinue using the old
* connection (e.g. using mobile c= onnection when WiFi becomes available */
- struct link_socket_info *lsi =3D get_link_socket_inf= o(c);
+ const stru= ct link_socket_info *lsi =3D get_link_socket_info(c);
= if (lsi && proto_is_tcp(lsi->proto) && !samenetwork)
{
return -2;
dif= f --git a/src/openvpn/list.c b/src/openvpn/list.c
index f0e= 9908..2e1cf05 100644
--- a/src/openvpn/list.c
+++ b/src/openvpn/list.c

@@ -165,7 +165,7 @@
<= span> hash_remove_by_value(struct hash *hash, void *value)

= {
struct hash_iterator hi;
- struct hash_element *he;
+ const struct hash_element *he;

hash_iterator_init(hash, &hi);

while ((he =3D hash_iterator_next(&hi)))
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
= index c082f51..604bbcd 100644
--- a/src/openvpn/manage.c

+++ b/src/openvpn/manage.c
@@ -3820,7 +3820,7= @@
{
int ok;
ch= ar *result =3D NULL;
- = struct buffer *buf;
- struct buffer *buf;
+ const struct buffer *buf;
=
ok =3D management_query_multiline(man, b64_data, pro= mpt, cmd, state, input);
if (ok && buffer_list= _defined(*input))
diff --git a/src/openvpn/misc.c b/src/ope= nvpn/misc.c
index 10bfc35..6563b83 100644
-= -- a/src/openvpn/misc.c
+++ b/src/openvpn/misc.c
= @@ -131,7 +131,7 @@
struct auth_challenge_info *= ac;
const int len =3D strlen(auth_challenge); char *work =3D (char *)gc_malloc(len + 1, false, gc);- char *cp;
+ const char *cp;
=
struct buffer b;
buf_set_read(&= amp;b, (const uint8_t *)auth_challenge, len);
diff --git a/= src/openvpn/mss.c b/src/openvpn/mss.c
index 14112b4..36bbb4= 3 100644
--- a/src/openvpn/mss.c
+++ b/src/= openvpn/mss.c
@@ -65,7 +65,7 @@
st= ruct buffer newbuf =3D *buf;
if (buf_advance(&= newbuf, hlen))
{
- struct openvpn_tcphdr *tc =3D (struct openv= pn_tcphdr *)BPTR(&newbuf);
+ const struct openvpn_tcphdr *tc =3D (struct openvpn_= tcphdr *)BPTR(&newbuf);
if (tc->flags &= amp; OPENVPN_TCPH_SYN_MASK)
{
= mss_fixup_dowork(&newbuf, maxmss);
@@ = -122,7 +122,7 @@
newbuf =3D *buf;
= if (buf_advance(&newbuf, 40) && BLENZ(&newbuf) >=3D siz= eof(struct openvpn_tcphdr))
{
- struct openvpn_tcphdr *tc =3D (struct = openvpn_tcphdr *)BPTR(&newbuf);
+ const struct openvpn_tcphdr *tc =3D (struct openvpn= _tcphdr *)BPTR(&newbuf);
if (tc->flags &= ; OPENVPN_TCPH_SYN_MASK)
{
= mss_fixup_dowork(&newbuf, maxmss - 20);
diff --gi= t a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c
index 7651b4d..= df94a70 100644
--- a/src/openvpn/mtcp.c
+++= b/src/openvpn/mtcp.c
@@ -130,7 +130,7 @@
= void
multi_tcp_dereference_instance(struct multi_io *multi= _io, struct multi_instance *mi)
{
- struct link_socket *sock =3D mi->contex= t.c2.link_sockets[0];
+ const struct link_socket *sock =3D mi->context.c2.link_sockets[0];=
if (sock && mi->socket_set_called)<= br> {
event_del(multi_io->es, socket_= event_handle(sock));
diff --git a/src/openvpn/mudp.c b/src/= openvpn/mudp.c
index 432c79a..50d72d5 100644
--- a/src/openvpn/mudp.c
+++ b/src/openvpn/mudp.c<= br>@@ -74,7 +74,7 @@
verdict =3D tls_pre_decrypt= _lite(tas, state, &m->top.c2.from, &m->top.c2.buf);
hmac_ctx_t *hmac =3D m->top.c2.session_id_= hmac;
- struct openv= pn_sockaddr *from =3D &m->top.c2.from.dest;
+ const struct openvpn_sockaddr *from =3D = &m->top.c2.from.dest;
int handwindow =3D m->= top.options.handshake_window;

if (ve= rdict =3D=3D VERDICT_VALID_RESET_V3 || verdict =3D=3D VERDICT_VALID_RESET_V= 2)
@@ -201,7 +201,7 @@
struct hash= _element *he;
const uint32_t hv =3D hash_value(has= h, &real);
struct hash_bucket *bucket =3D hash= _bucket(hash, hv);
- = uint8_t *ptr =3D BPTR(&m->top.c2.buf);
+ const uint8_t *ptr =3D BPTR(&m-&= gt;top.c2.buf);
uint8_t op =3D ptr[0] >> P_O= PCODE_SHIFT;
bool v2 =3D (op =3D=3D P_DATA_V2) &am= p;& (m->top.c2.buf.len >=3D (1 + 3));
bo= ol peer_id_disabled =3D false;
diff --git a/src/openvpn/mul= ti.c b/src/openvpn/multi.c
index a957fdf..ef39527 100644
--- a/src/openvpn/multi.c
+++ b/src/openvpn/m= ulti.c
@@ -86,7 +86,7 @@
struct gc_are= na gc =3D gc_new();
struct env_set *es;
bool ret =3D true;

- struct plugin_list *plugins;
+ const struct plugin_list *plugins;

/* get environmental variable source */
if (mi && mi->context.c2.es)

@@ -1794,7 +1= 794,7 @@
* Push the first cipher from --data-ciphers = to the client that
* the client announces to be suppo= rting.
*/
- char *push_cipher =3D
+ const char *push_cipher =3D
nc= p_get_best_cipher(o->ncp_ciphers, peer_info, tls_multi->remote_cipher= name, &o->gc);
if (push_cipher)
{
@@ -1925,7 +1925,7 @@
static enum = client_connect_return
ccs_test_deferred_ret_file(struct mu= lti_instance *mi)
{
- struct client_connect_defer_state *ccs =3D &(mi->= client_connect_defer_state);
+ const struct client_connect_defer_state *ccs =3D &(mi->= client_connect_defer_state);
FILE *fp =3D fopen(ccs-&g= t;deferred_ret_file, "r");
if (!fp) {
@@ -2166,7 +2166,7 @@
{
ASSERT(mi);
ASSERT(option_types_foun= d);
- struct client_= connect_defer_state *ccs =3D &(mi->client_connect_defer_state);

+ const struct client_= connect_defer_state *ccs =3D &(mi->client_connect_defer_state);
enum client_connect_return ret =3D CC_RET_SKIPPED;<= br>
ret =3D ccs_test_deferred_ret_file(mi);
@@ -2568,7 +2568,7 @@
override_locked_usernam= e(struct multi_instance *mi)
{
struct= tls_multi *multi =3D mi->context.c2.tls_multi;
- struct options *options =3D &mi->co= ntext.options;
+ c= onst struct options *options =3D &mi->context.options;
struct tls_session *session =3D &multi->session[TM_ACTIVE];<= /span>

if (!multi->locked_username)
@@ -2987,7 +2987,7 @@
{
#= if defined(ENABLE_ASYNC_PUSH)
bool was_unauthentic= ated =3D true;
- = struct key_state *ks =3D NULL;
+ const struct key_state *ks =3D NULL;
= if (mi->context.c2.tls_multi)
{ ks =3D &mi->context.c2.tls_multi->session[TM= _ACTIVE].key[KS_PRIMARY];
@@ -3104,7 +3104,7 @@
<= span> struct multi_instance *ex_mi =3D (struct multi_instance *)he-= >value;


struct tls_multi *m1 = =3D mi->context.c2.tls_multi;
- struct tls_multi *m2 =3D ex_mi->context.c2.tls_multi;=
+ const struc= t tls_multi *m2 =3D ex_mi->context.c2.tls_multi;

/* do not float if target address is taken by client wi= th another cert */
if (!cert_hash_compare(m1->l= ocked_cert_hash_set, m2->locked_cert_hash_set))
@@ -3864= ,7 +3864,7 @@
static int
management_callb= ack_n_clients(void *arg)
{
- struct multi_context *m =3D (struct multi_context= *)arg;
+ const st= ruct multi_context *m =3D (struct multi_context *)arg;
= return m->n_clients;
}

diff --git a/src/openvpn/networking_sitnl.c b/src/openvpn/networking_sit= nl.c

index b3f8e2b..e6e72d0 100644
--- a/sr= c/openvpn/networking_sitnl.c
+++ b/src/openvpn/networking_s= itnl.c
@@ -462,7 +462,7 @@
struct rtat= tr *rta =3D RTM_RTA(r);
size_t len =3D n->nlmsg_len= - NLMSG_LENGTH(sizeof(*r));
unsigned int table, ifind= ex =3D 0;
- void *gw= =3D NULL;
+ const= void *gw =3D NULL;

/* filter-out no= n-zero dst prefixes */
if (res->default_only &&= amp; r->rtm_dst_len !=3D 0)
@@ -1179,7 +1179,7 @@=
net_route_v4_add(openvpn_net_ctx_t *ctx, const in_addr_t *dst, i= nt prefixlen, const in_addr_t *gw,
const = char *iface, uint32_t table, int metric)
{
- in_addr_t *dst_ptr =3D NULL, *gw_= ptr =3D NULL;

+ co= nst in_addr_t *dst_ptr =3D NULL, *gw_ptr =3D NULL;
in_= addr_t dst_be =3D 0, gw_be =3D 0;
char dst_str[INET_AD= DRSTRLEN];
char gw_str[INET_ADDRSTRLEN];
@@ -1326,7 +1326,7 @@

#if defined(ENABLE_DCO) if (arg && (strcmp(type, OVPN_FAMILY_NAME) =3D=3D 0))
{
-= dco_context_t *dco =3D arg;
+ const dco_context_t *dco =3D arg;
= struct rtattr *data =3D SITNL_NEST(&req.n, sizeof(req), IFLA_IN= FO_DATA);

/* the netlink format = is uint8_t for this and using something
diff --git a/src/op= envpn/options.c b/src/openvpn/options.c
index 53fb060..fd0d= 3fc 100644
--- a/src/openvpn/options.c
+++ = b/src/openvpn/options.c
@@ -1877,7 +1877,7 @@
SHOW_INT(verify_hash_algo);

SHOW_INT(v= erify_hash_depth);
struct gc_arena gc =3D gc_new()= ;
- struct verif= y_hash_list *hl =3D o->verify_hash;
+ const struct verify_hash_list *hl =3D o->veri= fy_hash;
int digest_len =3D
= (o->verify_hash_algo =3D=3D MD_SHA1) ? SHA_DIGEST_LENGTH : SHA256= _DIGEST_LENGTH;
while (hl)
@@ -233= 3,7 +2333,7 @@

for (int i =3D 0; i &= lt; ce->local_list->len; i++)
{
- struct local_entry *le =3D ce-= >local_list->array[i];
+ const struct local_entry *le =3D ce->local_list->arr= ay[i];

if (proto_is_net(le->p= roto) && string_defined_equal(le->local, ce->remote) && string_defined_equal(le->port, ce->re= mote_port))
@@ -3988,7 +3988,7 @@
{
char *fullpath =3D
stri= ng_alloc(file, NULL); /* POSIX dirname() implementation may modify its argu= ments */
- char = *dirpath =3D dirname(fullpath);
+ const char *dirpath =3D dirname(fullpath);

if (platform_access(dirpath, mode | X_OK) != =3D 0)
{
@@ -4219,7 +4219,7 @@
ASSERT(options->connection_list);
= for (int i =3D 0; i < options->connection_list->len; ++i)<= br> {
- = struct connection_entry *ce =3D options->connection_list->array[i];=
+ const struc= t connection_entry *ce =3D options->connection_list->array[i];=

errs |=3D check_file_access_inline(ce-= >tls_auth_file_inline, CHKACC_FILE | CHKACC_PRIVATE,
= ce->tls_auth_file, R_OK, "--= tls-auth");
@@ -9091,7 +9091,7 @@
#if= def ENABLE_PKCS11
else if (streq(p[0], "show-pkcs= 11-ids") && !p[3])
{
- char *provider =3D p[1];+ const char *provider = =3D p[1];
bool cert_private =3D (p[2] =3D=3D NULL = ? false : (atoi_warn(p[2], msglevel) !=3D 0));

= #ifdef DEFAULT_PKCS11_MODULE
diff --git a/src/openvp= n/options_parse.c b/src/openvpn/options_parse.c
index a8c4a= ee..88ab4d2 100644
--- a/src/openvpn/options_parse.c=
+++ b/src/openvpn/options_parse.c
@@ -268,7 +268,= 7 @@
while (in_src_get(is, line, sizeof(line)))=
{
(*num_lines)++;
- char *line_ptr =3D line;=
+ const char *line_p= tr =3D line;
/* Remove leading spaces */ while (isspace(*line_ptr))
{
diff --git a/src/openvpn/options_util.c b/src/openvpn/options_ut= il.c
index 47fe0bc..dc4d3ea 100644
--- a/sr= c/openvpn/options_util.c
+++ b/src/openvpn/options_util.c
@@ -272,7 +272,7 @@
return true;
}

- struct pull_filter *f;
+ const struct pull_filter *f;
<= /span>
for (f =3D o->pull_filter_list->head; f; f =3D f= ->next)
{
diff --git a/src/openvpn/= pool.c b/src/openvpn/pool.c
index 15004c0..97f59f3 100644
--- a/src/openvpn/pool.c
+++ b/src/openvpn/p= ool.c
@@ -63,7 +63,7 @@

= for (i =3D 0; i < pool->size; ++i)
{<= br>- struct ifconfig_pool_= entry *ipe =3D &pool->list[i];
+ const struct ifconfig_pool_entry *ipe =3D &po= ol->list[i];
if (!ipe->in_use)
{

/*
diff --git a/= src/openvpn/proxy.c b/src/openvpn/proxy.c
index 9f3ec93..4d= e7615 100644
--- a/src/openvpn/proxy.c
+++ = b/src/openvpn/proxy.c
@@ -703,7 +703,7 @@
= #if PROXY_DIGEST_AUTH
else if (p->auth_method = =3D=3D HTTP_AUTH_DIGEST && !processed)
{
- char *pa = =3D p->proxy_authenticate;
+ const char *pa =3D p->proxy_authenticate; const int method =3D p->auth_method;
ASSERT(pa);


diff --git a/s= rc/openvpn/push.c b/src/openvpn/push.c
index ae0f0e2..a030a= cd 100644
--- a/src/openvpn/push.c
+++ b/sr= c/openvpn/push.c
@@ -271,8 +271,8 @@
}=
#ifdef ENABLE_MANAGEMENT
struct tls_= session *session =3D &c->c2.tls_multi->session[TM_ACTIVE];=
- struct man_def_auth_cont= ext *mda =3D session->opt->mda_context;
- struct env_set *es =3D session->opt->es;<= /span>
+ const struct man= _def_auth_context *mda =3D session->opt->mda_context;
+ const struct env_set *es =3D se= ssion->opt->es;

unsigned int mda_key_id =3D get_= primary_key(c->c2.tls_multi)->mda_key_id;
management_notify_client_cr_response(mda_key_id, mda, es, m);
@@ -913,7 +913,7 @@
push_options(struct opt= ions *o, char **p, msglvl_t msglevel, struct gc_arena *gc)
= {
const char **argv =3D make_extended_arg_array(p, fa= lse, gc);
- char *op= t =3D print_argv(argv, gc, 0);
+ const char *opt =3D print_argv(argv, gc, 0);
push_option(o, opt, msglevel);

}

@@ -1197,7 +1197,7 @@
/= * parse route-ipv6 arguments */
if (ge= t_ipv6_addr(p[1], &network, &netbits, D_ROUTE_DEBUG))
{

- struct iroute_ipv6 *ir;
+ const struct irou= te_ipv6 *ir;

/* = does this route-ipv6 match an iroute-ipv6? */
= for (ir =3D o->iroutes_ipv6; ir !=3D NULL; ir =3D ir->nex= t)
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index ed77efe..3dca4ec 100644
--- a/src/open= vpn/route.c
+++ b/src/openvpn/route.c
@@ -6= 67,7 +667,7 @@

/* parse the routes f= rom opt to rl */
{
- struct route_option *ro;
+ const struct route_option *ro;
for (ro =3D opt->routes; ro; ro =3D ro->next)
{
struct addrinfo *netli= st =3D NULL;
@@ -799,7 +799,7 @@
need_= remote_ipv6_route =3D false;

{
- struct route_ipv6_o= ption *ro6;
+ = const struct route_ipv6_option *ro6;
for (ro6 =3D = opt6->routes_ipv6; ro6; ro6 =3D ro6->next)
{=
struct route_ipv6 *r6;
@@ -11= 87,7 +1187,7 @@
{
if (rl6 && = (rl6->iflags & RL_ROUTES_ADDED))
{
- struct route_ipv6 *r6;
+ const struct ro= ute_ipv6 *r6;
for (r6 =3D rl6->routes_ipv6; r6;= r6 =3D r6->next)
{
= delete_route_ipv6(r6, tt, es, ctx);
@@ -1226,7 +1226,7 @@=
void
print_route_options(const struct ro= ute_option_list *rol, msglvl_t msglevel)
{
- struct route_option *ro;
+ const struct route_optio= n *ro;
if (rol->flags & RG_ENABLE)
{

msg(msglevel, " [redirect_default= _gateway local=3D%d]", (rol->flags & RG_LOCAL) !=3D 0);<= br>@@ -1335,7 +1335,7 @@
setenv_routes(struct env_se= t *es, const struct route_list *rl)
{
= int i =3D 1;
- stru= ct route_ipv4 *r;
+ = const struct route_ipv4 *r;
for (r =3D rl->routes= ; r; r =3D r->next)
{
sete= nv_route(es, r, i++);
@@ -1372,7 +1372,7 @@
setenv_routes_ipv6(struct env_set *es, const struct route_ipv6_list *rl6)=

{
int i =3D 1;
- struct route_ipv6 *r6;
+ const struct route_ipv6 *r6;
for (r6 =3D rl6->routes_ipv6; r6; r6 =3D r6->next)<= /span>
{
setenv_route_ipv6(es, r6, i= ++);
@@ -2423,7 +2423,7 @@
*/
if (rl && tt->did_ifconfig_setup) {
- = struct route_ipv4 *r;
+ const struct route_ipv4 *r;
= for (r =3D rl->routes, len =3D 0; r; r =3D r->next, ++len)
{
test_route_helpe= r(&ret, &count, &good, &ambig, adapters, r->gateway);
@@ -3110,7 +3110,8 @@
/* scan adapter li= st */
if (rgi->flags & RGI_ADDR_DEFINED)=
{
- = struct ifreq *ifr, *ifend;
+ struct ifreq *ifr;
+ const struct ifreq *ifend;
= in_addr_t addr, netmask;
struct ifreq ifreq;
struct ifconf ifc;
diff --git a/src/o= penvpn/socket.c b/src/openvpn/socket.c
index da6f870..332c4= 6e 100644
--- a/src/openvpn/socket.c
+++ b/= src/openvpn/socket.c
@@ -393,7 +393,7 @@
<= /span>
for (int j =3D 0; j < ce->local_list->= ;len; j++)
{
- struct local_entry *le =3D ce->local= _list->array[j];
+= const struct local_entry *le =3D ce->local_list->arra= y[j];

if (!le->local)=
{
@@ -926,12 +926,10 @@
* What is the correct way to deal with it?
<= span> */


- struct addrinfo *cur;
-
ASSERT(local);
=
-
/* fin= d the first addrinfo with correct ai_family */
+ const struct addrinfo *cur;
= for (cur =3D local; cur; cur =3D cur->ai_next)
= {
if (cur->ai_family =3D=3D ai_family)<= br>@@ -1514,7 +1512,7 @@
/* Socket is always= bound on the first matching address,
* For bound= sockets with no remote addr this is the element of
= * the list */
- = struct addrinfo *cur;
+ const struct addrinfo *cur;
for (cur = =3D sock->info.lsa->bind_local; cur; cur =3D cur->ai_next)<= br> {
if (!ai_family || ai_famil= y =3D=3D cur->ai_family)
@@ -1645,7 +1643,7 @@ create_socket_dco_win(struct context *c, struct link_socket *sock, = struct signal_info *sig_info)
{
/* in= P2P mode we must have remote resolved at this point */
- struct addrinfo *remoteaddr =3D sock-= >info.lsa->current_remote;
+ const struct addrinfo *remoteaddr =3D sock->info.lsa-&g= t;current_remote;
if ((c->options.mode =3D=3D MODE_= POINT_TO_POINT) && (!remoteaddr))
{
= return;
@@ -1930,7 +1928,7 @@
const struct link_socket_actual *from_addr= )

{
struct gc_arena gc =3D gc_new();<= /span>
- struct addrinfo *a= i;
+ const struct = addrinfo *ai;

switch (from_addr->= dest.addr.sa.sa_family)
{
diff --git a= /src/openvpn/socket.h b/src/openvpn/socket.h
index 6196af0.= .71a3595 100644
--- a/src/openvpn/socket.h
= +++ b/src/openvpn/socket.h
@@ -762,7 +762,7 @@
{

if (sock && ipbuf)
= {
- struct open= vpn_iphdr *iph =3D (struct openvpn_iphdr *)BPTR(ipbuf);
+ const struct openvpn_iphdr *iph= =3D (struct openvpn_iphdr *)BPTR(ipbuf);
sock->= ;ptos =3D iph->tos;
sock->ptos_defined =3D t= rue;
}
diff --git a/src/openvpn/ssl.c = b/src/openvpn/ssl.c
index d332359c..7f3b4dc 100644--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -1478,7 +1478,7 @@
static bool
<= span> generate_key_expansion(struct tls_multi *multi, struct key_state *ks,= struct tls_session *session)

{
- struct key_ctx_bi *key =3D &ks->crypt= o_options.key_ctx_bi;
+ const struct key_ctx_bi *key =3D &ks->crypto_options.key_ctx_b= i;
bool ret =3D false;
struct key= 2 key2;

@@ -1740,7 +1740,7 @@
<= span> static void

flush_payload_buffer(struct key_state *k= s)
{
-= struct buffer *b;
+ const struct buffer *b;

while = ((b =3D buffer_list_peek(ks->paybuf)))
{
= @@ -2719,7 +2719,7 @@
/* Outgoing Ciphertext to = reliable buffer */
if (ks->state >=3D S_START)
{
-= struct buffer *buf =3D reliable_get_buf_output_sequenced(ks->sen= d_reliable);
+ = const struct buffer *buf =3D reliable_get_buf_output_sequenced(ks->send= _reliable);
if (buf)
{
if (!write_outgoing_tls_ciphertext(session, cont= inue_tls_process))
@@ -2788,7 +2788,7 @@
= {
int opcode;

- struct buffer *buf =3D reliab= le_send(ks->send_reliable, &opcode);

+ const struct buffer *buf =3D reliable_send(= ks->send_reliable, &opcode);
ASSERT(buf);
struct buffer b =3D *buf;
= INCR_SENT;
@@ -3151,7 +3151,7 @@
static vo= id
check_session_buf_not_used(struct buffer *to_link, stru= ct tls_session *session)
{
- uint8_t *dataptr =3D to_link->data;
= + const uint8_t *dataptr =3D= to_link->data;
if (!dataptr)
= {
return;
@@ -3167,7 +3167,7 @@

for (int i =3D 0; i < KS_SIZE; i++)=
{
- struct key_state *ks =3D &session->key[i];
+ const struct key_state *ks = =3D &session->key[i];

if (ks->state =3D= =3D S_UNDEF)
{
contin= ue;
@@ -3232,7 +3232,7 @@
{
= struct tls_session *session =3D &multi->session[i];
struct key_state *ks =3D &session->key[KS_PR= IMARY];
- struct= key_state *ks_lame =3D &session->key[KS_LAME_DUCK];
+ const struct key_state *ks_= lame =3D &session->key[KS_LAME_DUCK];


/* set initial remote address. This triggers connecting with t= hat

* session. So we only do that if the TM_ACTIV= E session is not
@@ -3433,7 +3433,7 @@

for (int i =3D 0; i < KEY_SCAN_SIZE; ++i)
<= span> {

- st= ruct key_state *ks =3D get_key_scan(multi, i);
+ const struct key_state *ks =3D get_key_s= can(multi, i);
if (ks->key_id !=3D key_id)
{
continue;
@@ -3985,7 +3985,7 @@

void
tls_prepend= _opcode_v1(const struct tls_multi *multi, struct buffer *buf)
{

- struct key_s= tate *ks =3D multi->save_ks;
+ const struct key_state *ks =3D multi->save_ks;
msg(D_TLS_DEBUG, __func__);
=
@@ -3999,7 +3999,7 @@
void
tls_prepend_opcode_v2(const struct tls_multi *multi, struct buffer *buf)=

{
- = struct key_state *ks =3D multi->save_ks;
+ const struct key_state *ks =3D multi->save= _ks;
uint32_t peer;

= msg(D_TLS_DEBUG, __func__);
diff --git a/src/openvpn/s= sl_mbedtls.c b/src/openvpn/ssl_mbedtls.c
index 8a0f7d2..9d4= 08c0 100644
--- a/src/openvpn/ssl_mbedtls.c
+++ b/src/openvpn/ssl_mbedtls.c

@@ -301,7 +301,7 @@=
void
tls_ctx_restrict_ciphers(struct tls_root_c= tx *ctx, const char *ciphers)
{
- char *tmp_ciphers, *tmp_ciphers_orig, *token= ;
+ char *tmp_ciph= ers, *tmp_ciphers_orig;

if (NULL =3D= =3D ciphers)
{
@@ -320,7 +320,7 @@
int i =3D 0;
tmp_ciphers_orig =3D tm= p_ciphers =3D string_alloc(ciphers, NULL);

- token =3D strtok(tmp_ciphers, &q= uot;:");

+ co= nst char *token =3D strtok(tmp_ciphers, ":");
= while (token)
{
ctx->all= owed_ciphers[i] =3D mbedtls_ssl_get_ciphersuite_id(tls_translate_cipher_nam= e(token));
@@ -744,7 +744,7 @@
static inli= ne size_t
external_key_len(void *vctx)
{<= /span>
- struct external_co= ntext *const ctx =3D vctx;
+ const struct external_context *const ctx =3D vctx;

return ctx->signature_length;
= }
diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_= verify.c
index 0804d2d..e5b55a1 100644
--- = a/src/openvpn/ssl_verify.c
+++ b/src/openvpn/ssl_verify.c
@@ -409,7 +409,7 @@
con= st char *subject, const struct x509_track *x509_track)
{
char envname[64];
- char *serial =3D NULL;
+ const char *serial =3D NULL;
= struct gc_arena gc =3D gc_new();

/= * Save X509 fields in environment */
@@ -699,7 +699,7 @@
goto cleanup;
}

- = struct verify_hash_list *current_hash =3D opt->verify_hash;
<= span style=3D"color: hsl(120, 100%, 40%);">+ const struct verify_has= h_list *current_hash =3D opt->verify_hash;


<= span> while (current_hash)

{
@@ -1530,7 +1530,7 @@

verify_user_pass_management(struc= t tls_session *session, const struct user_pass *up)
{
int retval =3D KMDA_ERROR;
- struct key_state *ks =3D &session->key[KS_= PRIMARY]; /* primary key */
+ const struct key_state *ks =3D &session->key[KS_PRIMARY]= ; /* primary key */

/* set username/= password in private env space */
setenv_str(session-&g= t;opt->es, "password", up->password);
diff = --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index f46802f= ..0103588 100644
--- a/src/openvpn/tun.c
++= + b/src/openvpn/tun.c
@@ -1735,7 +1735,7 @@
{

u_int32_t type;
s= truct iovec iv[2];
- = struct ip *iph =3D (struct ip *)buf;
+ const struct ip *iph =3D (struct ip *)buf;

if (iph->ip_v =3D=3D 6)<= br> {
diff --git a/src/openvpn/win32.c b/src/= openvpn/win32.c
index 5ee65fb..1dc8e3b 100644
--- a/src/openvpn/win32.c

+++ b/src/openvpn/win32.c
@@ -889,7 +889,7 @@

if (= es)
{
- struct env_item *e;
+ const struct env_item *e;
cha= r *ret;
char *p;
size_t n= chars =3D 1;
diff --git a/src/openvpnmsica/msica_arg.c b/sr= c/openvpnmsica/msica_arg.c
index a334710..d763d93 100644
--- a/src/openvpnmsica/msica_arg.c
+++ b/src/= openvpnmsica/msica_arg.c
@@ -92,7 +92,7 @@
= {
/* Count required space. */
si= ze_t size =3D 2 /*x + zero-terminator*/;
- for (struct msica_arg *p =3D seq->head; p !=3D NU= LL; p =3D p->next)
+ for (const struct msica_arg *p =3D seq->head; p !=3D NULL; p =3D p= ->next)
{
size +=3D wcslen= (p->val) + 1 /*space delimiter|zero-terminator*/;
}=
@@ -119,7 +119,7 @@

= /* Join. */
LPWSTR s =3D str + 1 /*x*/;
- for (struct msica_arg *p =3D se= q->head; p !=3D NULL; p =3D p->next)

+ for (const struct msica_arg *p =3D seq->head;= p !=3D NULL; p =3D p->next)
{
= /* Convert zero-terminator into space delimiter. */
= s[0] =3D L' ';
diff --git a/src/openvpnmsica= /openvpnmsica.c b/src/openvpnmsica/openvpnmsica.c
index d69= 8c04..6a71801 100644
--- a/src/openvpnmsica/openvpnmsica.c<= /span>
+++ b/src/openvpnmsica/openvpnmsica.c
@@ -1= 96,7 +196,7 @@

/* Count adapters. */=
size_t adapter_count =3D 0;
- for (struct tap_adapter_node *pAdapter =3D = pAdapterList; pAdapter; pAdapter =3D pAdapter->pNext)
+ for (const struct tap_adapter_node= *pAdapter =3D pAdapterList; pAdapter; pAdapter =3D pAdapter->pNext)
{
adapter_count++;
}

diff --git a/src/plugins/auth-pam/auth-pam.c b/sr= c/plugins/auth-pam/auth-pam.c
index 3b7bcc2..948b6af 100644=
--- a/src/plugins/auth-pam/auth-pam.c
+++ = b/src/plugins/auth-pam/auth-pam.c
@@ -526,7 +526,7 @@
openvpn_plugin_func_v1(openvpn_plugin_handle_t handle, const in= t type, const char *argv[],
const c= har *envp[])
{
- struct auth_pam_context *context =3D (struct auth_pam_context= *)handle;
+ const= struct auth_pam_context *context =3D (struct auth_pam_context *)handle;

if (type =3D=3D OPENVPN_PLUGIN_AUTH_US= ER_PASS_VERIFY && context->foreground_fd >=3D 0)
{

diff --git a/src/tapctl/main.c b/src/tapctl/main= .c
index 6a4a240..6697d14 100644
--- a/src/= tapctl/main.c
+++ b/src/tapctl/main.c
@@ -3= 17,7 +317,7 @@
return NULL;
= }

- struct tap_adapter_node *conflict =3D find_adapter_by_name(req= uested_name, adapter_list);
+ const struct tap_adapter_node *conflict =3D find_adapter_by= _name(requested_name, adapter_list);
if (conflict)=
{
LPOLESTR adapter_i= d =3D NULL;
diff --git a/tests/unit_tests/openvpn/test_buff= er.c b/tests/unit_tests/openvpn/test_buffer.c
index 326de40= ..ce38bbe 100644
--- a/tests/unit_tests/openvpn/test_buffer= .c
+++ b/tests/unit_tests/openvpn/test_buffer.c
<= span>@@ -88,7 +88,7 @@


int maxoutput= =3D 0;
unsigned int blocksize =3D 5;
- char *separator =3D " ";=
+ const char *sep= arator =3D " ";
output =3D format_hex_ex(inp= ut, input_size, maxoutput, blocksize, separator, &gc);
= assert_string_equal(output, "0100ff10ff 00f00f090a");=

@@ -174,7 +174,7 @@
/* Wit= h a max length of 2, no aggregation should take place */
= buffer_list_aggregate_separator(ctx->one_two_three, 2, testsep);
assert_int_equal(ctx->one_two_three->size, 3);
- struct buffer *buf =3D = buffer_list_peek(ctx->one_two_three);
+ const struct buffer *buf =3D buffer_list_peek(ctx-= >one_two_three);
assert_buf_equals_str(buf, teststr= 1);
}

@@ -189,7 +189,7 @= @
*/
buffer_list_aggregate_separ= ator(ctx->one_two_three, strlen(expected) + 1, testsep);
assert_int_equal(ctx->one_two_three->size, 2);

- struct buffer *buf =3D buffer_list= _peek(ctx->one_two_three);
+ const struct buffer *buf =3D buffer_list_peek(ctx->one_two= _three);
assert_buf_equals_str(buf, expected);<= br> }

@@ -201,7 +201,7 @@ /* Aggregate all */
buffer_list_aggregate_= separator(ctx->one_two_three, 1 << 16, testsep);
= assert_int_equal(ctx->one_two_three->size, 1);
- struct buffer *buf =3D buffer_list_p= eek(ctx->one_two_three);
+ const struct buffer *buf =3D buffer_list_peek(ctx->one_two_t= hree);
assert_buf_equals_str(buf, teststr1 testsep tes= tstr2 testsep teststr3 testsep);
}

@@ -213,7 +213,7 @@
/* Aggregate all */
buffer_list_aggregate_separator(ctx->one_two_three, 1 = << 16, testnosep);
assert_int_equal(ctx->one_= two_three->size, 1);
- struct buffer *buf =3D buffer_list_peek(ctx->one_two_three);
+ const struct buffer *= buf =3D buffer_list_peek(ctx->one_two_three);
asser= t_buf_equals_str(buf, teststr1 teststr2 teststr3);
}

@@ -226,7 +226,7 @@
/* Ag= gregate all */
buffer_list_aggregate_separator(bl_zero= len, 1 << 16, testnosep);
assert_int_equal(bl_ze= rolen->size, 1);
- = struct buffer *buf =3D buffer_list_peek(bl_zerolen);
+ const struct buffer *buf =3D buffer_= list_peek(bl_zerolen);
assert_buf_equals_str(buf, &quo= t;");
}

@@ -239,7 += 239,7 @@
/* Aggregate all */
buff= er_list_aggregate_separator(bl_emptybuffers, 1 << 16, testnosep);
assert_int_equal(bl_emptybuffers->size, 1);
= - struct buffer *buf =3D buffe= r_list_peek(bl_emptybuffers);
+ const struct buffer *buf =3D buffer_list_peek(bl_emptybuffers= );
assert_int_equal(BLEN(buf), 0);
}<= /span>

diff --git a/tests/unit_tests/openvpn/tes= t_crypto.c b/tests/unit_tests/openvpn/test_crypto.c
index c= b4eaa2..8393e1c 100644
--- a/tests/unit_tests/openvpn/test_= crypto.c
+++ b/tests/unit_tests/openvpn/test_crypto.c
@@ -479,9 +479,9 @@
crypto_test_hkdf_expand_tes= ta1(void **state)
{
/* RFC 5889 A.1 T= est Case 1 */
- uint= 8_t prk[32] =3D { 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, 0x0d, 0xd= c, 0x3f,
- = 0x0d, 0xc4, 0x7b, 0xba, 0x63, 0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f= ,
- = 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5 };+ const uint8_t prk[32] =3D= { 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, 0x0d, 0xdc, 0x3f,=
+ = 0x0d, 0xc4, 0x7b, 0xba, 0x63, 0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f,
+ = 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5 };
uint8_t info[10] =3D { 0xf0, 0xf1, 0xf2, 0xf= 3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9 };

= @@ -500,9 +500,9 @@
crypto_test_hkdf_expand_testa2(void **= state)
{
/* RFC 5889 A.2 Test Case 2 = */
- uint8_t prk[32]= =3D { 0x06, 0xa6, 0xb8, 0x8c, 0x58, 0x53, 0x36, 0x1a, 0x06, 0x10, 0x4c,
- = 0x9c, 0xeb, 0x35, 0xb4, 0x5c, 0xef, 0x76, 0x00, 0x14, 0x90, 0x46,- 0x71, 0= x01, 0x4a, 0x19, 0x3f, 0x40, 0xc1, 0x5f, 0xc2, 0x44 };
+ const uint8_t prk[32] =3D { 0x06, 0x= a6, 0xb8, 0x8c, 0x58, 0x53, 0x36, 0x1a, 0x06, 0x10, 0x4c,
+ 0x9c, 0= xeb, 0x35, 0xb4, 0x5c, 0xef, 0x76, 0x00, 0x14, 0x90, 0x46,
+ 0x71, = 0x01, 0x4a, 0x19, 0x3f, 0x40, 0xc1, 0x5f, 0xc2, 0x44 };

uint8_t info[80] =3D { 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0x= b5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb,
= 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0x= c7,
@@ -531,11 +531,11 @@
crypto_test_hkdf= _expand_testa3(void **state)
{
/* RFC= 5889 A.3 Test Case 3 */
- = 0x1d, 0x6f, 0x64, 0x8b, 0xdf, 0x96, 0x59, 0x67, 0x76,= 0xaf, 0xdb,
- = 0x63, 0x77, 0xac, 0x43, 0x4c, 0x1c, 0x29, 0x3c, 0xcb, 0x04 }= ;
+ const uint8_t = prk[32] =3D { 0x19, 0xef, 0x24, 0xa3, 0x2c, 0x71, 0x7b, 0x16, 0x7f, 0x33, 0= xa9,
+ = 0x1d, 0x6f, 0x64, 0x8b, 0xdf, 0x96, 0x59, 0x67, 0x76, 0xaf, = 0xdb,
+ = 0x63, 0x77, 0xac, 0x43, 0x4c, 0x1c, 0x29, 0x3c, 0xcb, 0x04 = };

- = uint8_t info[] =3D { 0 };
+ const uint8_t info[] =3D { 0 };

int L =3D 42;

uint8_t okm[42] =3D { 0x8d, 0xa= 4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, 0x71, 0x5f, 0x80,
@@= -555,9 +555,9 @@
/* tests the HDKF with a label/okm t= hat OpenVPN itself uses in OpenSSL 3
* HDKF unit test= */

- = uint8_t prk[32] =3D { 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, 0x= 0d, 0xdc, 0x3f,
- = 0x0d, 0xc4, 0x7b, 0xba, 0x63, 0x90, 0xb6, 0xc7, 0x3b, 0xb= 5, 0x0f,
- = 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5 };
+ const uint8_t prk[= 32] =3D { 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, 0x0d, 0xdc, 0x3f,=
+ = 0x0d, 0xc4, 0x7b, 0xba, 0x63, 0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f= ,
+ = 0x9c, 0x31, 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5 };

uint8_t info[18] =3D { 0x00, 0x1b, 0x= 0e, 0x6f, 0x76, 0x70, 0x6e, 0x20, 0x75,
= 0x6e, 0x69, 0x74, 0x20, 0x74, 0x65, 0x73, 0x74, 0x00 };
@@ -677,7 +677,7 @@

static int
crypto= _test_epoch_setup(void **state)
{
- uint16_t *num_future_keys =3D (uint16_t *)= *state;
+ const ui= nt16_t *num_future_keys =3D (uint16_t *)*state;
struct= epoch_test_state *data =3D calloc(1, sizeof(struct epoch_test_state));

data->gc =3D gc_new();
diff --git a/tests/unit_tests/openvpn/test_cryptoapi.c b/tests/unit_test= s/openvpn/test_cryptoapi.c

index 508afc9..37bbe92 100644
--- a/tests/unit_tests/openvpn/test_cryptoapi.c
+++ b/tests/unit_tests/openvpn/test_cryptoapi.c

@@ -233,= 7 +233,7 @@
const CERT_CONTEXT *ctx =3D NULL;
while ((ctx =3D CertEnumCertificatesInStore(user_store= , ctx)))
{
- char *friendly_name =3D get_cert_name(ctx, &g= c);
+ cons= t char *friendly_name =3D get_cert_name(ctx, &gc);
= if (!lookup_cert(friendly_name)) /* not our cert */
{

continue;
@@ -310,7 +310,7 @@

*/
= assert_non_null(ctx);

- char *friendly_name =3D get_cert_name(ctx, &g= c);
+ const ch= ar *friendly_name =3D get_cert_name(ctx, &gc);
= struct test_cert *found =3D lookup_cert(friendly_name);
= assert_non_null(found);
assert_string_equal= (found->cname, c->cname);
@@ -343,7 +343,7 @@<= br> */
assert_non_null(ctx);=

- ch= ar *friendly_name =3D get_cert_name(ctx, &gc);
+ const char *friendly_name =3D get_ce= rt_name(ctx, &gc);
struct test_cert *found =3D= lookup_cert(friendly_name);
assert_non_null(found= );
assert_string_equal(found->issuer, c->iss= uer);
diff --git a/tests/unit_tests/openvpn/test_misc.c b/t= ests/unit_tests/openvpn/test_misc.c
index a9ae33f..4a055e7 = 100644
--- a/tests/unit_tests/openvpn/test_misc.c+++ b/tests/unit_tests/openvpn/test_misc.c
@@ -301,7= +301,7 @@
{
for (ptr_type i = =3D 1; i <=3D 16; ++i)
{
- struct hash_element *item =3D h= ash_lookup_by_value(nhash, (void *)i);
+ const struct hash_element *item =3D hash_loo= kup_by_value(nhash, (void *)i);
hash_remove_by= _value(nhash, (void *)i);
/* check item got re= moved if it was present before */
if (item)
diff --git a/tests/unit_tests/openvpn/test_pkt.c b/tests/unit= _tests/openvpn/test_pkt.c
index cad2ce0..df9fed7 100644
--- a/tests/unit_tests/openvpn/test_pkt.c
+++ = b/tests/unit_tests/openvpn/test_pkt.c
@@ -567,7 +567,7 @@
ASSERT(md_valid("SHA256"));
= hmac_ctx_t *hmac_ctx =3D hmac_ctx_new();

- uint8_t key[SHA256_DIGEST_LENG= TH] =3D { 1, 2, 3, 0 };

+ const uint8_t key[SHA256_DIGEST_LENGTH] =3D { 1, 2, 3, 0 };<= br>
hmac_ctx_init(hmac_ctx, key, "SHA256&q= uot;);
return hmac_ctx;
diff --git a/t= ests/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn/test_ssl.c
index c40845a..9f5d34a 100644
--- a/tests/uni= t_tests/openvpn/test_ssl.c
+++ b/tests/unit_tests/openvpn/t= est_ssl.c
@@ -683,7 +683,7 @@
openvpn_= encrypt(&buf, encrypt_workspace, &co);

= /* separate buffer in authenticated data and encrypted data */
- uint8_t *ad_start = =3D BPTR(&buf);
+= const uint8_t *ad_start =3D BPTR(&buf);
buf_ad= vance(&buf, 4);

if (epoch)
diff --git a/tests/unit_tests/plugins/auth-pam/test_search_and_r= eplace.c b/tests/unit_tests/plugins/auth-pam/test_search_and_replace.c
index a861bfd..89f0642 100644
--- a/tests/unit_= tests/plugins/auth-pam/test_search_and_replace.c
+++ b/test= s/unit_tests/plugins/auth-pam/test_search_and_replace.c
@@ = -12,7 +12,7 @@
static void
pass_any_null_= param__returns_null(void **state)
{
- char DUMMY[] =3D "DUMMY";
+ const char DUMMY[] = =3D "DUMMY";

assert_null(s= earchandreplace(NULL, DUMMY, DUMMY));
assert_null(sear= chandreplace(DUMMY, NULL, DUMMY));
@@ -22,8 +22,8 @@=
static void
pass_any_empty_string__returns_null= (void **state)
{
- char DUMMY[] =3D "DUMMY";
- char EMPTY[] =3D "";+ const char DUMMY[] =3D &= quot;DUMMY";
+ = const char EMPTY[] =3D "";

= assert_null(searchandreplace(EMPTY, DUMMY, DUMMY));
= assert_null(searchandreplace(DUMMY, EMPTY, DUMMY));

To view, visit change 1661. To unsubscribe, or for help writing m= ail filters, visit settings.

<= /div>
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2b71dae37ebe63c26a66761f877= b25d326ed140f
Gerrit-Change-Number: 1661
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --BfFWfMPAScY=--