From 91cc8081a2eff2e3d7d9f63411c2b6cf1e183923 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Wed, 5 Apr 2017 01:37:20 -0400 Subject: [PATCH] DOC: update sample code for PROXY protocol lengths are in network byte order so use ntohs(hdr.v2.len) when calculating size of v2 header to recv() from head of stream. --- doc/proxy-protocol.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/proxy-protocol.txt b/doc/proxy-protocol.txt index e7888f62d..358bce0a4 100644 --- a/doc/proxy-protocol.txt +++ b/doc/proxy-protocol.txt @@ -970,7 +970,7 @@ side is even simpler and can easily be deduced from this sample code. if (ret >= 16 && memcmp(&hdr.v2, v2sig, 12) == 0 && (hdr.v2.ver_cmd & 0xF0) == 0x20) { - size = 16 + hdr.v2.len; + size = 16 + ntohs(hdr.v2.len); if (ret < size) return -1; /* truncated or too large header */