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.

52 lines
1.9 KiB

  1. From 8e05ac2044c6523c867ceaaae1f10486370eec89 Mon Sep 17 00:00:00 2001
  2. From: Thierry FOURNIER <tfournier@haproxy.com>
  3. Date: Mon, 16 Mar 2015 11:14:41 +0100
  4. Subject: [PATCH 6/9] BUG/MAJOR: http: don't read past buffer's end in
  5. http_replace_value
  6. The function http_replace_value use bad variable to detect the end
  7. of the input string.
  8. Regression introduced by the patch "MEDIUM: regex: Remove null
  9. terminated strings." (c9c2daf2)
  10. We need to backport this patch int the 1.5 stable branch.
  11. WT: there is no possibility to overwrite existing data as we only read
  12. past the end of the request buffer, to copy into the trash. The copy
  13. is bounded by buffer_replace2(), just like the replacement performed
  14. by exp_replace(). However if a buffer happens to contain non-zero data
  15. up to the next unmapped page boundary, there's a theorical risk of
  16. crashing the process despite this not being reproducible in tests.
  17. The risk is low because "http-request replace-value" did not work due
  18. to this bug so that probably means it's not used yet.
  19. (cherry picked from commit 534101658d6e19aeb598bf7833a8ce167498c4ed)
  20. ---
  21. src/proto_http.c | 4 ++--
  22. 1 file changed, 2 insertions(+), 2 deletions(-)
  23. diff --git a/src/proto_http.c b/src/proto_http.c
  24. index 705f3b4..f53b5e2 100644
  25. --- a/src/proto_http.c
  26. +++ b/src/proto_http.c
  27. @@ -3206,7 +3206,7 @@ static int http_replace_value(struct my_regex *re, char *dst, uint dst_size, cha
  28. /* look for delim. */
  29. p_delim = p;
  30. - while (p_delim < p + len && *p_delim != delim)
  31. + while (p_delim < val + len && *p_delim != delim)
  32. p_delim++;
  33. if (regex_exec_match2(re, p, p_delim-p, MAX_MATCH, pmatch)) {
  34. @@ -3230,7 +3230,7 @@ static int http_replace_value(struct my_regex *re, char *dst, uint dst_size, cha
  35. return -1;
  36. /* end of the replacements. */
  37. - if (p_delim >= p + len)
  38. + if (p_delim >= val + len)
  39. break;
  40. /* Next part. */
  41. --
  42. 2.0.5