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.

44 lines
1.7 KiB

  1. commit 6e580b6e744011e87c337ebe2c082acfd5ca835a
  2. Author: Christopher Faulet <cfaulet@haproxy.com>
  3. Date: Tue Apr 30 14:03:56 2019 +0200
  4. MINOR: config: Test validity of tune.maxaccept during the config parsing
  5. Only -1 and positive integers from 0 to INT_MAX are accepted. An error is
  6. triggered during the config parsing for any other values.
  7. This patch may be backported to all supported versions.
  8. (cherry picked from commit 6b02ab87348090efec73b1dd24f414239669f279)
  9. Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
  10. (cherry picked from commit 2bbc40f8bc9a52ba0d03b25270ac0129cca29bba)
  11. Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
  12. diff --git a/src/cfgparse.c b/src/cfgparse.c
  13. index c178538b..8e325416 100644
  14. --- a/src/cfgparse.c
  15. +++ b/src/cfgparse.c
  16. @@ -789,6 +789,8 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
  17. global.tune.maxpollevents = atol(args[1]);
  18. }
  19. else if (!strcmp(args[0], "tune.maxaccept")) {
  20. + long max;
  21. +
  22. if (alertif_too_many_args(1, file, linenum, args, &err_code))
  23. goto out;
  24. if (global.tune.maxaccept != 0) {
  25. @@ -801,7 +803,13 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
  26. err_code |= ERR_ALERT | ERR_FATAL;
  27. goto out;
  28. }
  29. - global.tune.maxaccept = atol(args[1]);
  30. + max = atol(args[1]);
  31. + if (/*max < -1 || */max > INT_MAX) {
  32. + ha_alert("parsing [%s:%d] : '%s' expects -1 or an integer from 0 to INT_MAX.\n", file, linenum, args[0]);
  33. + err_code |= ERR_ALERT | ERR_FATAL;
  34. + goto out;
  35. + }
  36. + global.tune.maxaccept = max;
  37. }
  38. else if (!strcmp(args[0], "tune.chksize")) {
  39. if (alertif_too_many_args(1, file, linenum, args, &err_code))