Hello Ilya,

Thanks for the report.

On 15.9.2017. 19:08, Илья Шипицин wrote:
> hello,
> 
> [contrib/halog/halog.c:1572]: (error) Memory leak: ustat
> [contrib/mod_defender/defender.c:153]: (error) va_list 'argp' was opened
> but not closed by va_end().
> [contrib/modsecurity/modsec_wrapper.c:109]: (error) va_list 'ap' was
> opened but not closed by va_end().
> [src/51d.c:373]: (error) Invalid number of character '{' when no macros
> are defined.
> [src/dns.c:2502]: (error) Memory leak: buffer
> [src/haproxy.c:568]: (error) Common realloc mistake: 'next_argv' nulled
> but not freed upon failure
> 

Patches for contrib/mod_defender and contrib/modsecurity attached.

Best regards,
Dragan Dosen
From 83136038ef5cd6725b512b8f42540e8a003aaabd Mon Sep 17 00:00:00 2001
From: Dragan Dosen <ddo...@haproxy.com>
Date: Mon, 18 Sep 2017 08:20:33 +0200
Subject: [PATCH 1/2] BUG/MINOR: contrib/mod_defender: close the va_list argp
 before return

Fix the case when the va_list argp could be left open if the function
vsnprintf() returned a negative value.
---
 contrib/mod_defender/defender.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/mod_defender/defender.c b/contrib/mod_defender/defender.c
index c86d25e..1734176 100644
--- a/contrib/mod_defender/defender.c
+++ b/contrib/mod_defender/defender.c
@@ -149,9 +149,10 @@ static char *defender_printf(apr_pool_t *pool, const char 
*fmt, ...)
 
        va_start(argp, fmt);
        len = vsnprintf(NULL, 0, fmt, argp);
+       va_end(argp);
+
        if (len < 0)
                return NULL;
-       va_end(argp);
 
        if (!(dst = apr_pcalloc(pool, len + 1)))
                return NULL;
-- 
2.7.4

From aae4701f55bca2ee3c56e4a2f8524d85ea3498f4 Mon Sep 17 00:00:00 2001
From: Dragan Dosen <ddo...@haproxy.com>
Date: Mon, 18 Sep 2017 09:20:43 +0200
Subject: [PATCH 2/2] BUG/MINOR: contrib/modsecurity: close the va_list ap
 before return

Make sure the va_list ap is closed before return in case the function
vsnprintf() returned an error.
---
 contrib/modsecurity/modsec_wrapper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/contrib/modsecurity/modsec_wrapper.c 
b/contrib/modsecurity/modsec_wrapper.c
index 8927b5b..271ec15 100644
--- a/contrib/modsecurity/modsec_wrapper.c
+++ b/contrib/modsecurity/modsec_wrapper.c
@@ -105,9 +105,10 @@ static char *printf_dup(struct request_rec *req, char 
*fmt, ...)
 
        va_start(ap, fmt);
        len = vsnprintf(NULL, 0, fmt, ap);
+       va_end(ap);
+
        if (len == -1)
                return NULL;
-       va_end(ap);
 
        out = apr_pcalloc(req->pool, len + 1);
        if (!out)
@@ -115,9 +116,10 @@ static char *printf_dup(struct request_rec *req, char 
*fmt, ...)
 
        va_start(ap, fmt);
        len = vsnprintf(out, len + 1, fmt, ap);
+       va_end(ap);
+
        if (len == -1)
                return NULL;
-       va_end(ap);
 
        return out;
 }
-- 
2.7.4

Reply via email to