]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: log: Detect missing sampling ranges in config
authorTim Duesterhus <tim@bastelstu.be>
Sun, 23 Jun 2019 20:10:10 +0000 (22:10 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 26 Jun 2019 09:15:49 +0000 (11:15 +0200)
Consider a config like:

    global
     log 127.0.0.1:10001 sample :10 local0

No sampling ranges are given here, leading to NULL being passed
as the first argument to qsort.

This configuration does not make sense anyway, a log without ranges
would never log. Thus output an error if no ranges are given.

This bug was introduced in d95ea2897eb951c72fd169f36b6a79905f2ed999.
This fix must be backported to HAProxy 2.0.

src/log.c

index ecbc7ab55975d4effa8726dcae8490909d40eebf..ef999d13f58908908aed535995f4b04a837311e3 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -929,6 +929,11 @@ int parse_logsrv(char **args, struct list *logsrvs, int do_del, char **err)
                        smp_rgs_sz++;
                }
 
+               if (smp_rgs == NULL) {
+                       memprintf(err, "no sampling ranges given");
+                       goto error;
+               }
+
                beg = smp_sz_str;
                end = beg + strlen(beg);
                new_smp_sz = read_uint((const char **)&beg, end);