You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.7 KiB

  1. commit f6d20e718131aa2b468ff0a6c42e20c0b900e58b
  2. Author: Ilya Shipitsin <chipitsine@gmail.com>
  3. Date: Sat Sep 15 00:50:05 2018 +0500
  4. BUG/MINOR: connection: avoid null pointer dereference in send-proxy-v2
  5. found by coverity.
  6. [wt: this bug was introduced by commit 404d978 ("MINOR: add ALPN
  7. information to send-proxy-v2"). It might be triggered by a health
  8. check on a server using ppv2 or by an applet making use of such a
  9. server, if at all configurable].
  10. This needs to be backported to 1.8.
  11. (cherry picked from commit ca56fce8bd271928b18d38b439bd35bd273fe8d4)
  12. Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
  13. diff --git a/src/connection.c b/src/connection.c
  14. index 8c5af156..7403e8ae 100644
  15. --- a/src/connection.c
  16. +++ b/src/connection.c
  17. @@ -874,6 +874,7 @@ int conn_recv_netscaler_cip(struct connection *conn, int flag)
  18. return 0;
  19. }
  20. +/* Note: <remote> is explicitly allowed to be NULL */
  21. int make_proxy_line(char *buf, int buf_len, struct server *srv, struct connection *remote)
  22. {
  23. int ret = 0;
  24. @@ -985,6 +986,7 @@ static int make_tlv(char *dest, int dest_len, char type, uint16_t length, const
  25. return length + sizeof(*tlv);
  26. }
  27. +/* Note: <remote> is explicitly allowed to be NULL */
  28. int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct connection *remote)
  29. {
  30. const char pp2_signature[] = PP2_SIGNATURE;
  31. @@ -1060,7 +1062,7 @@ int make_proxy_line_v2(char *buf, int buf_len, struct server *srv, struct connec
  32. }
  33. }
  34. - if (conn_get_alpn(remote, &value, &value_len)) {
  35. + if (remote && conn_get_alpn(remote, &value, &value_len)) {
  36. if ((buf_len - ret) < sizeof(struct tlv))
  37. return 0;
  38. ret += make_tlv(&buf[ret], (buf_len - ret), PP2_TYPE_ALPN, value_len, value);