From be6a87309662c3942352ac22af16376968b5c50b Mon Sep 17 00:00:00 2001 From: William Lallemand Date: Thu, 22 Dec 2022 15:37:01 +0100 Subject: [PATCH] BUG/MINOR: httpclient/log: free of invalid ptr with httpclient_log_format 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 | 1 + src/http_client.c | 2 -- src/log.c | 1 + src/proxy.c | 3 ++- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/haproxy/log.h b/include/haproxy/log.h index ac839c351..1715a0c9d 100644 --- a/include/haproxy/log.h +++ b/include/haproxy/log.h @@ -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[]; diff --git a/src/http_client.c b/src/http_client.c index 338bab31a..c6fc6ba77 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -39,8 +39,6 @@ #include -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 diff --git a/src/log.c b/src/log.c index cf140cdd9..61072d6ad 100644 --- 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"; diff --git a/src/proxy.c b/src/proxy.c index dc7a95fb8..1279da6f2 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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);