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.

39 lines
1.5 KiB

  1. commit 69d4ddf919fc4bc6d296a743baeccdd44fb89be6
  2. Author: Willy Tarreau <w@1wt.eu>
  3. Date: Sun Oct 28 20:13:12 2018 +0100
  4. BUG/MAJOR: http: http_txn_get_path() may deference an inexisting buffer
  5. When the "path" sample fetch function is called without any path, the
  6. function doesn't check that the request buffer is allocated. While this
  7. doesn't happen with the request during processing, it can definitely
  8. happen when mistakenly trying to reference a path from the response
  9. since the request channel is not allocated anymore.
  10. It's certain that this bug was emphasized by the buffer changes that
  11. went in 1.9 and the HTTP refactoring, but at first glance, 1.8 doesn't
  12. seem 100% safe either so it's possible that older version are affected
  13. as well.
  14. Thanks to PiBa-NL for reporting this bug with a reproducer.
  15. (cherry picked from commit 9d9ccdbf8b1178fefa2843c83bc6612733f9eca6)
  16. [wt: minor adaptation to older buffer API. There are some call places
  17. which don't look structurally safe though in their context the
  18. buffer always ought to be there]
  19. Signed-off-by: Willy Tarreau <w@1wt.eu>
  20. diff --git a/src/proto_http.c b/src/proto_http.c
  21. index a48c4fdb..fb18357b 100644
  22. --- a/src/proto_http.c
  23. +++ b/src/proto_http.c
  24. @@ -985,6 +985,9 @@ char *http_get_path(struct http_txn *txn)
  25. {
  26. char *ptr, *end;
  27. + if (!txn->req.chn->buf->size)
  28. + return NULL;
  29. +
  30. ptr = txn->req.chn->buf->p + txn->req.sl.rq.u;
  31. end = ptr + txn->req.sl.rq.u_l;