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.

48 lines
1.5 KiB

  1. From a581cf03110f13c61faeaf87efa5b4e2777087d0 Mon Sep 17 00:00:00 2001
  2. From: Willy Tarreau <w@1wt.eu>
  3. Date: Wed, 10 Aug 2016 19:29:09 +0200
  4. Subject: [PATCH 20/26] BUILD: checks: remove the last strcat and eliminate a
  5. warning on OpenBSD
  6. OpenBSD emits warnings on usages of strcpy, strcat and sprintf (and
  7. probably a few others). Here we have a single such warning in all the code
  8. reintroduced by commit 0ba0e4a ("MEDIUM: Support sending email alerts") in
  9. 1.6-dev1. Let's get rid of it, the open-coding of strcat is as small as its
  10. usage and the the result is even more efficient.
  11. This fix needs to be backported to 1.6.
  12. (cherry picked from commit 64345aaaf0dc2739983902cce4667089ad926a49)
  13. ---
  14. src/checks.c | 7 +++++--
  15. 1 file changed, 5 insertions(+), 2 deletions(-)
  16. diff --git a/src/checks.c b/src/checks.c
  17. index 80b2fc3..55c13a9 100644
  18. --- a/src/checks.c
  19. +++ b/src/checks.c
  20. @@ -3164,6 +3164,8 @@ static int add_tcpcheck_expect_str(struct list *list, const char *str)
  21. static int add_tcpcheck_send_strs(struct list *list, const char * const *strs)
  22. {
  23. struct tcpcheck_rule *tcpcheck;
  24. + const char *in;
  25. + char *dst;
  26. int i;
  27. tcpcheck = calloc(1, sizeof *tcpcheck);
  28. @@ -3181,10 +3183,11 @@ static int add_tcpcheck_send_strs(struct list *list, const char * const *strs)
  29. free(tcpcheck);
  30. return 0;
  31. }
  32. - tcpcheck->string[0] = '\0';
  33. + dst = tcpcheck->string;
  34. for (i = 0; strs[i]; i++)
  35. - strcat(tcpcheck->string, strs[i]);
  36. + for (in = strs[i]; (*dst = *in++); dst++);
  37. + *dst = 0;
  38. LIST_ADDQ(list, &tcpcheck->list);
  39. return 1;
  40. --
  41. 2.7.3