]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: vars: Fix memory leak in vars_check_arg
authorTim Duesterhus <tim@bastelstu.be>
Fri, 10 May 2019 15:50:50 +0000 (17:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 11 May 2019 04:00:50 +0000 (06:00 +0200)
commit6ea00195c479d96c5aa651adcca3bc3637e3eceb
tree093b3ff468b5903e96a810ffc2cba4120422cd4d
parentddf0e03585d3d8d8fb01566198faf3561fe392c3
BUG/MINOR: vars: Fix memory leak in vars_check_arg

vars_check_arg previously leaked the string containing the variable
name:

Consider this config:

    frontend fe1
        mode http
        bind :8080
        http-request set-header X %[var(txn.host)]

Starting HAProxy and immediately stopping it by sending a SIGINT makes
Valgrind report this leak:

    ==7795== 9 bytes in 1 blocks are definitely lost in loss record 15 of 71
    ==7795==    at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==7795==    by 0x4AA2AD: my_strndup (standard.c:2227)
    ==7795==    by 0x51FCC5: make_arg_list (arg.c:146)
    ==7795==    by 0x4CF095: sample_parse_expr (sample.c:897)
    ==7795==    by 0x4BA7D7: add_sample_to_logformat_list (log.c:495)
    ==7795==    by 0x4BBB62: parse_logformat_string (log.c:688)
    ==7795==    by 0x4E70A9: parse_http_req_cond (http_rules.c:239)
    ==7795==    by 0x41CD7B: cfg_parse_listen (cfgparse-listen.c:1466)
    ==7795==    by 0x480383: readcfgfile (cfgparse.c:2089)
    ==7795==    by 0x47A081: init (haproxy.c:1581)
    ==7795==    by 0x4049F2: main (haproxy.c:2591)

This leak can be detected even in HAProxy 1.6, this patch thus should
be backported to all supported branches.
src/vars.c