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.

41 lines
1.3 KiB

  1. From 106cb89907ea6eab0073708bb8d6f56d7fc64509 Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Tue, 25 Oct 2016 17:05:56 +0200
  4. Subject: [PATCH 14/26] BUG/MINOR: systemd: check return value of calloc()
  5. The wrapper is not the best reliable thing in the universe, so start
  6. by adding at least the minimum expected controls :-/
  7. To be backported to 1.5 and 1.6.
  8. (cherry picked from commit 3747ea07ce6b647b86559383f7d09b42550d42f3)
  9. ---
  10. src/haproxy-systemd-wrapper.c | 10 ++++++++--
  11. 1 file changed, 8 insertions(+), 2 deletions(-)
  12. diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
  13. index 84d2e17..15c48ca 100644
  14. --- a/src/haproxy-systemd-wrapper.c
  15. +++ b/src/haproxy-systemd-wrapper.c
  16. @@ -77,11 +77,17 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
  17. pid = fork();
  18. if (!pid) {
  19. - /* 3 for "haproxy -Ds -sf" */
  20. - char **argv = calloc(4 + main_argc + nb_pid + 1, sizeof(char *));
  21. + char **argv;
  22. int i;
  23. int argno = 0;
  24. + /* 3 for "haproxy -Ds -sf" */
  25. + argv = calloc(4 + main_argc + nb_pid + 1, sizeof(char *));
  26. + if (!argv) {
  27. + fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: failed to calloc(), please try again later.\n");
  28. + exit(1);
  29. + }
  30. +
  31. reset_signal_handler();
  32. locate_haproxy(haproxy_bin, 512);
  33. argv[argno++] = haproxy_bin;
  34. --
  35. 2.7.3