]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: checks: remove the last strcat and eliminate a warning on OpenBSD
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Aug 2016 17:29:09 +0000 (19:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Aug 2016 17:32:39 +0000 (19:32 +0200)
OpenBSD emits warnings on usages of strcpy, strcat and sprintf (and
probably a few others). Here we have a single such warning in all the code
reintroduced by commit 0ba0e4a ("MEDIUM: Support sending email alerts") in
1.6-dev1. Let's get rid of it, the open-coding of strcat is as small as its
usage and the the result is even more efficient.

This fix needs to be backported to 1.6.

src/checks.c

index 51864e38914eaf9f0498220084ac5f71cccecce3..5d026420b533446791dcc2abfe3adb46ef594d52 100644 (file)
@@ -3177,6 +3177,8 @@ static int add_tcpcheck_expect_str(struct list *list, const char *str)
 static int add_tcpcheck_send_strs(struct list *list, const char * const *strs)
 {
        struct tcpcheck_rule *tcpcheck;
+       const char *in;
+       char *dst;
        int i;
 
        tcpcheck = calloc(1, sizeof *tcpcheck);
@@ -3194,10 +3196,11 @@ static int add_tcpcheck_send_strs(struct list *list, const char * const *strs)
                free(tcpcheck);
                return 0;
        }
-       tcpcheck->string[0] = '\0';
 
+       dst = tcpcheck->string;
        for (i = 0; strs[i]; i++)
-               strcat(tcpcheck->string, strs[i]);
+               for (in = strs[i]; (*dst = *in++); dst++);
+       *dst = 0;
 
        LIST_ADDQ(list, &tcpcheck->list);
        return 1;