From: William Lallemand Date: Tue, 25 Jul 2023 07:57:02 +0000 (+0200) Subject: BUG/MINOR: sample: check alloc_trash_chunk() in conv_time_common() X-Git-Tag: v2.9-dev3~99 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=202b8e34a2b74d6050a33dda967ce37ac2eb2aca;p=thirdparty%2Fhaproxy.git BUG/MINOR: sample: check alloc_trash_chunk() in conv_time_common() Check the trash chunk allocation in conv_time_common(), also remove the data initialisation which is already done when allocating. Fixes issue #2227. No backported needed. --- diff --git a/src/sample.c b/src/sample.c index 9450042fdd..2fd7b357a1 100644 --- a/src/sample.c +++ b/src/sample.c @@ -2285,10 +2285,10 @@ static struct buffer *conv_time_common(const char *format, time_t curr_date, uin width = 9; cpy = needle - p; - if (!tmp_format) { - tmp_format = alloc_trash_chunk(); - tmp_format->data = 0; - } + if (!tmp_format) + tmp_format = alloc_trash_chunk(); + if (!tmp_format) + goto error; if (set != 9) /* if the snprintf wasn't done yet */ set = snprintf(ns_str, sizeof(ns_str), "%.9llu", (unsigned long long)ns);