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.4 KiB

  1. From ff403602edc917b8bef2062dc0d5dec2017e3232 Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Fri, 21 Oct 2016 17:14:35 +0200
  4. Subject: [PATCH 08/26] BUG/MINOR: vars: make smp_fetch_var() more robust
  5. against misuses
  6. smp_fetch_var() may be called from everywhere since it just reads a
  7. variable. It must ensure that the stream exists before trying to return
  8. a stream-dependant variable. For now there is no impact but it will
  9. cause trouble with tcp-request session rules.
  10. (cherry picked from commit 7513d001c8a6b7d1cf8e7d5469942cd39d6e8160)
  11. ---
  12. src/vars.c | 16 +++++++++++++---
  13. 1 file changed, 13 insertions(+), 3 deletions(-)
  14. diff --git a/src/vars.c b/src/vars.c
  15. index b22c3bf..4a0c4ed 100644
  16. --- a/src/vars.c
  17. +++ b/src/vars.c
  18. @@ -242,11 +242,21 @@ static int smp_fetch_var(const struct arg *args, struct sample *smp, const char
  19. /* Check the availibity of the variable. */
  20. switch (var_desc->scope) {
  21. - case SCOPE_SESS: vars = &smp->sess->vars; break;
  22. - case SCOPE_TXN: vars = &smp->strm->vars_txn; break;
  23. + case SCOPE_SESS:
  24. + vars = &smp->sess->vars;
  25. + break;
  26. + case SCOPE_TXN:
  27. + if (!smp->strm)
  28. + return 0;
  29. + vars = &smp->strm->vars_txn;
  30. + break;
  31. case SCOPE_REQ:
  32. case SCOPE_RES:
  33. - default: vars = &smp->strm->vars_reqres; break;
  34. + default:
  35. + if (!smp->strm)
  36. + return 0;
  37. + vars = &smp->strm->vars_reqres;
  38. + break;
  39. }
  40. if (vars->scope != var_desc->scope)
  41. return 0;
  42. --
  43. 2.7.3