]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DOC: proxy protocol example parser was still wrong
authorWilly Tarreau <w@1wt.eu>
Sat, 14 Jun 2014 06:36:29 +0000 (08:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 14 Jun 2014 09:46:02 +0000 (11:46 +0200)
Now that version and cmd are in the same byte, it is not possible
anymore to compare the version as a 13th byte.

doc/proxy-protocol.txt

index b8d4379171e2a3cea1b48fca4d6d9483cbb5edd4..b0ec08b080c6f653c518aafacf644f9370e5d961 100644 (file)
@@ -751,7 +751,7 @@ side is even simpler and can easily be deduced from this sample code.
 
   struct sockaddr_storage from; /* already filled by accept() */
   struct sockaddr_storage to;   /* already filled by getsockname() */
-  const char v2sig[13] = "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A\x02";
+  const char v2sig[12] = "\x0D\x0A\x0D\x0A\x00\x0D\x0A\x51\x55\x49\x54\x0A";
 
   /* returns 0 if needs to poll, <0 upon error or >0 if it did the job */
   int read_evt(int fd)
@@ -795,7 +795,8 @@ side is even simpler and can easily be deduced from this sample code.
       if (ret == -1)
           return (errno == EAGAIN) ? 0 : -1;
 
-      if (ret >= 16 && memcmp(&hdr.v2, v2sig, 13) == 0) {
+      if (ret >= 16 && memcmp(&hdr.v2, v2sig, 12) == 0 &&
+          (hdr.v2.ver_cmd & 0xF0) == 0x20) {
           size = 16 + hdr.v2.len;
           if (ret < size)
               return -1; /* truncated or too large header */