]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: httpclient/log: free of invalid ptr with httpclient_log_format
authorWilliam Lallemand <wlallemand@haproxy.org>
Thu, 22 Dec 2022 14:37:01 +0000 (15:37 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 22 Dec 2022 14:39:31 +0000 (15:39 +0100)
free_proxy() must check if the ptr is not httpclient_log_format before
trying to free p->conf.logformat_string.

No backport needed.

include/haproxy/log.h
src/http_client.c
src/log.c
src/proxy.c

index ac839c351289a30c7201ae5a064a54a99a8dd55f..1715a0c9d282db9bf79612352fb9515f442f4fe3 100644 (file)
@@ -35,6 +35,7 @@ extern struct pool_head *pool_head_uniqueid;
 
 extern const char *log_levels[];
 extern char *log_format;
+extern char httpclient_log_format[];
 extern char default_tcp_log_format[];
 extern char default_http_log_format[];
 extern char clf_http_log_format[];
index 338bab31a149d24b4c9024c522d31e37a0ad174f..c6fc6ba770e5181b09b43bffc9b37417ff3765dc 100644 (file)
@@ -39,8 +39,6 @@
 
 #include <string.h>
 
-static char httpclient_log_format[] = "%ci:%cp [%tr] %ft -/- %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r";
-
 static struct proxy *httpclient_proxy;
 
 #ifdef USE_OPENSSL
index cf140cdd9930e535201e1bfd38b4c754e9f8b183..61072d6ad5732e373682bb91d16338a88a825d93 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -194,6 +194,7 @@ static const struct logformat_type logformat_keywords[] = {
        { 0, 0, 0, 0, NULL }
 };
 
+char httpclient_log_format[] = "%ci:%cp [%tr] %ft -/- %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r";
 char default_http_log_format[] = "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"; // default format
 char default_https_log_format[] = "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r %[fc_err]/%[ssl_fc_err,hex]/%[ssl_c_err]/%[ssl_c_ca_err]/%[ssl_fc_is_resumed] %[ssl_fc_sni]/%sslv/%sslc";
 char clf_http_log_format[] = "%{+Q}o %{-Q}ci - - [%trg] %r %ST %B \"\" \"\" %cp %ms %ft %b %s %TR %Tw %Tc %Tr %Ta %tsc %ac %fc %bc %sc %rc %sq %bq %CC %CS %hrl %hsl";
index dc7a95fb8aac6674497ad05fe1953b68bbbe36e1..1279da6f26ee51f7e44f6f946a11dd13009d5915 100644 (file)
@@ -178,7 +178,8 @@ void free_proxy(struct proxy *p)
        if (p->conf.logformat_string != default_http_log_format &&
            p->conf.logformat_string != default_tcp_log_format &&
            p->conf.logformat_string != clf_http_log_format &&
-           p->conf.logformat_string != default_https_log_format)
+           p->conf.logformat_string != default_https_log_format &&
+           p->conf.logformat_string != httpclient_log_format)
                free(p->conf.logformat_string);
 
        free(p->conf.lfs_file);