Commit 25589674 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

vrt: Perform IP to STRING conversion on the stack

Performing the conversion on the stack could lead to a buffer too small
to store the string representation of the IP address. There is no test
case because the error handling is output to stderr.

Refs #3765

Conflicts:
	bin/varnishd/cache/cache_vrt.c
parent bec48849
......@@ -597,21 +597,16 @@ VRT_r_now(VRT_CTX)
VCL_STRING v_matchproto_()
VRT_IP_string(VRT_CTX, VCL_IP ip)
{
char *p;
unsigned len;
char buf[VTCP_ADDRBUFSIZE];
struct vsb vsb[1];
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (ip == NULL)
return (NULL);
len = WS_ReserveAll(ctx->ws);
if (len == 0) {
WS_Release(ctx->ws, 0);
return (NULL);
}
p = ctx->ws->f;
VTCP_name(ip, p, len, NULL, 0);
WS_Release(ctx->ws, strlen(p) + 1);
return (p);
VTCP_name(ip, buf, sizeof buf, NULL, 0);
WS_VSB_new(vsb, ctx->ws);
VSB_cat(vsb, buf);
return (WS_VSB_finish(vsb, ctx->ws, NULL));
}
VCL_STRING v_matchproto_()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment