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.
This commit is contained in:
William Lallemand 2022-12-22 15:37:01 +01:00
parent d793ca28b6
commit be6a873096
4 changed files with 4 additions and 3 deletions

View 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[];

View 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

View File

@ -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";

View 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);