diff mbox series

[ovs-dev] dynamic-string: Add checking an empty template string for strtime.

Message ID dc7-6745ac80-5b-3c3e9a40@186771509
State Not Applicable
Headers show
Series [ovs-dev] dynamic-string: Add checking an empty template string for strtime. | expand

Commit Message

Виталий Листратенко Nov. 26, 2024, 11:09 a.m. UTC
If the template is empty, cyclic memory allocation occurs, which leads to
an out-of-memory error.  Its neccessary to check tepmplate string, and if
it is empty, terminate the function.
Testing performed via Libfuzzer.
Signed-off-by: Vitaly Listratenko <vlistratenko@astralinux.ru>

---
diff mbox series

Patch

diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c
index 8e9555a63..241cff26f 100644
--- a/lib/dynamic-string.c
+++ b/lib/dynamic-string.c
@@ -195,6 +195,10 @@  void
ds_put_strftime_msec(struct ds *ds, const char *template, long long int when,
                     bool utc)
{
+    if (template == NULL || *template == '\0') {
+        return;
+    }
+
    struct tm_msec tm;
    if (utc) {
        gmtime_msec(when, &tm);