Hi Tim,

On 6/23/19 10:10 PM, Tim Duesterhus wrote:
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.

Calling qsort() with such a <base> value is not a bug as far as the second argument (the size of the array with <base> as address) is 0.

See 7.20.5 http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

This bug was introduced in d95ea2897eb951c72fd169f36b6a79905f2ed999.
This fix must be backported to HAProxy 2.0.
---
  src/log.c | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/src/log.c b/src/log.c
index ecbc7ab55..ef999d13f 100644
--- 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);


I think this patch is correct but does not fix a bug. It helps the user in debugging its wrong configuration file.


Fred.

Reply via email to