Skip to content

Commit 34120e3

Browse files
Use a new variable pp2_hdr_len for the v2 header
1 parent ac6bbf2 commit 34120e3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

examples/client_server.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int main()
7474
}
7575
}
7676
};
77+
uint16_t pp2_hdr_len;
7778
/* Add SSL TLVs */
7879
/* IMPORTANT: Always clear the pp_info to be passed in pp_create_hdr() because TLVs are allocated in heap. Otherwise memory will be leaked */
7980
if (!pp_info_add_ssl(&pp_info_in_v2, "TLSv1.2", "ECDHE-RSA-AES128-GCM-SHA256", "SHA256", "RSA2048", "example.com", 11))
@@ -89,7 +90,7 @@ int main()
8990
pp_info_clear(&pp_info_in_v2);
9091
return EXIT_FAILURE;
9192
}
92-
uint8_t *pp2_hdr = pp_create_hdr(2, &pp_info_in_v2, &pp1_hdr_len, &error);
93+
uint8_t *pp2_hdr = pp_create_hdr(2, &pp_info_in_v2, &pp2_hdr_len, &error);
9394
pp_info_clear(&pp_info_in_v2);
9495
if (error != ERR_NULL)
9596
{
@@ -98,7 +99,7 @@ int main()
9899
}
99100

100101
/* Parse a v2 PROXY protocol header */
101-
rc = pp_parse_hdr(pp2_hdr, pp1_hdr_len, &pp_info_out);
102+
rc = pp_parse_hdr(pp2_hdr, pp2_hdr_len, &pp_info_out);
102103
free(pp2_hdr);
103104
if (!rc)
104105
{
@@ -127,6 +128,7 @@ int main()
127128
"\tSSL CN: %.*s\n"
128129
"\t%s %s %hu %hu\n",
129130
rc, linkid,
131+
/* In case CRC32c is wrong then rc < 0 => pp_strerror(rc) at previous block will print the error */
130132
pp_info_out.pp2_info.crc32c == 1 ? "verified" : "not present",
131133
pp_info_get_ssl_version(&pp_info_out, &length),
132134
pp_info_get_ssl_cipher(&pp_info_out, &length),

0 commit comments

Comments
 (0)