[master] a74315bce format proxy header on the stack
Nils Goroll
nils.goroll at uplex.de
Wed Jan 15 16:12:08 UTC 2020
commit a74315bcebce9aae690e53847581e7f94033eff1
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Apr 16 18:13:56 2019 +0200
format proxy header on the stack
diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index 0c829dc11..2ee6f82d2 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -689,19 +689,24 @@ VPX_Format_Proxy(struct vsb *vsb, int version,
WRONG("Wrong proxy version");
}
+#define PXY_BUFSZ \
+ sizeof(vpx1_sig) + 4 /* TCPx */ + \
+ 2 * VTCP_ADDRBUFSIZE + 2 * VTCP_PORTBUFSIZE + \
+ 6 /* spaces, CRLF */ + 16 /* safety */
+
int
VPX_Send_Proxy(int fd, int version, const struct sess *sp)
{
- struct vsb *vsb, *vsb2;
+ struct vsb vsb[1], *vsb2;
struct suckaddr *sac, *sas;
char ha[VTCP_ADDRBUFSIZE];
char pa[VTCP_PORTBUFSIZE];
+ char buf[PXY_BUFSZ];
int proto, r;
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
assert(version == 1 || version == 2);
- vsb = VSB_new_auto();
- AN(vsb);
+ AN(VSB_new(vsb, buf, sizeof buf, VSB_FIXEDLEN));
AZ(SES_Get_server_addr(sp, &sas));
AN(sas);
@@ -737,3 +742,5 @@ VPX_Send_Proxy(int fd, int version, const struct sess *sp)
VSB_delete(vsb2);
return (r);
}
+
+#undef PXY_BUFSZ
More information about the varnish-commit
mailing list