]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: sample: check alloc_trash_chunk() in conv_time_common()
authorWilliam Lallemand <wlallemand@haproxy.org>
Tue, 25 Jul 2023 07:57:02 +0000 (09:57 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 25 Jul 2023 08:05:29 +0000 (10:05 +0200)
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.

src/sample.c

index 9450042fddec46ead3ae18e1084568385de9b442..2fd7b357a1dc440366b63c5ce593dd445452de8e 100644 (file)
@@ -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);