[master] 25b2dc31d Constify the result from VPX_tlv()
Poul-Henning Kamp
phk at FreeBSD.org
Mon Dec 12 14:54:06 UTC 2022
commit 25b2dc31d8ec92aedb9fe49e90ccc6a0702b33ca
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Dec 12 14:53:07 2022 +0000
Constify the result from VPX_tlv()
diff --git a/bin/varnishd/proxy/cache_proxy.h b/bin/varnishd/proxy/cache_proxy.h
index 6fdfe6078..413759f94 100644
--- a/bin/varnishd/proxy/cache_proxy.h
+++ b/bin/varnishd/proxy/cache_proxy.h
@@ -40,6 +40,6 @@
#define PP2_SUBTYPE_SSL_KEY_ALG 0x25
#define PP2_SUBTYPE_SSL_MAX 0x25
-int VPX_tlv(const struct req *req, int tlv, void **dst, int *len);
+int VPX_tlv(const struct req *req, int tlv, const void **dst, int *len);
void VPX_Format_Proxy(struct vsb *, int, const struct suckaddr *,
const struct suckaddr *, const char *);
diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index b36ae0f6b..dc3f55a77 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -286,7 +286,7 @@ vpx_tlv_itern(struct vpx_tlv_iter *vpi)
(vpi->e == NULL) && vpx_tlv_itern(itv);)
int
-VPX_tlv(const struct req *req, int typ, void **dst, int *len)
+VPX_tlv(const struct req *req, int typ, const void **dst, int *len)
{
struct vpx_tlv *tlv;
struct vpx_tlv_iter vpi[1], vpi2[1];
diff --git a/vmod/vmod_proxy.c b/vmod/vmod_proxy.c
index 099f64a0b..7da8b2ea8 100644
--- a/vmod/vmod_proxy.c
+++ b/vmod/vmod_proxy.c
@@ -55,11 +55,11 @@ struct pp2_tlv_ssl {
static VCL_BOOL
tlv_ssl_flag(VRT_CTX, int flag)
{
- struct pp2_tlv_ssl *dst;
+ const struct pp2_tlv_ssl *dst;
int len;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- if (VPX_tlv(ctx->req, PP2_TYPE_SSL, (void **)&dst, &len))
+ if (VPX_tlv(ctx->req, PP2_TYPE_SSL, (const void **)&dst, &len))
return (0);
return ((dst->client & flag) == flag);
@@ -87,11 +87,11 @@ vmod_client_has_cert_conn(VRT_CTX)
VCL_INT v_matchproto_(td_proxy_ssl_verify_result)
vmod_ssl_verify_result(VRT_CTX)
{
- struct pp2_tlv_ssl *dst;
+ const struct pp2_tlv_ssl *dst;
int len;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- if (VPX_tlv(ctx->req, PP2_TYPE_SSL, (void **)&dst, &len))
+ if (VPX_tlv(ctx->req, PP2_TYPE_SSL, (const void **)&dst, &len))
return (0); /* X509_V_OK */
return (vbe32dec(&dst->verify));
@@ -100,19 +100,21 @@ vmod_ssl_verify_result(VRT_CTX)
static VCL_STRING
tlv_string(VRT_CTX, int tlv)
{
- char *dst, *d;
+ const char *ptr;
+ char *d;
int len;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- if (VPX_tlv(ctx->req, tlv, (void **)&dst, &len))
+ if (VPX_tlv(ctx->req, tlv, (const void **)&ptr, &len))
return (NULL);
d = WS_Alloc(ctx->ws, len+1);
if (d == NULL) {
VRT_fail(ctx, "proxy.TLV: out of workspace");
return (NULL);
}
- memcpy(d, dst, len);
+ AN(ptr);
+ memcpy(d, ptr, len);
d[len] = '\0';
return (d);
}
More information about the varnish-commit
mailing list