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