zlog: fix CVE-2024-22857

Backport a fix from upstream
c47f781a9f

Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
This commit is contained in:
Ankur Tyagi 2025-10-04 09:44:47 +13:00 committed by Gyorgy Sarvari
parent 1f3dd92f7b
commit dead2a0070
2 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,31 @@
From bffbd94a0807efbab0f449b13d622d3cffa224a4 Mon Sep 17 00:00:00 2001
From: Ali Raza <elirazamumtaz@gmail.com>
Date: Thu, 29 Feb 2024 11:36:25 +0500
Subject: [PATCH] CVE-2024-22857: buffer overflow patched
CVE: CVE-2024-22857
Upstream-Status: Backport [https://github.com/HardySimpson/zlog/commit/c47f781a9f1e9604f5201e27d046d925d0d48ac4]
(cherry picked from commit c47f781a9f1e9604f5201e27d046d925d0d48ac4)
Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com>
---
src/rule.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/rule.c b/src/rule.c
index ae3d74f..38d3fdc 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -866,8 +866,10 @@ zlog_rule_t *zlog_rule_new(char *line,
}
break;
case '$' :
- sscanf(file_path + 1, "%s", a_rule->record_name);
-
+ // read only MAXLEN_PATH characters from the file_path + 1
+ strncpy(a_rule->record_name, file_path + 1, MAXLEN_PATH);
+ a_rule->record_name[MAXLEN_PATH] = '\0';
+
if (file_limit) { /* record path exists */
p = strchr(file_limit, '"');
if (!p) {

View File

@ -4,7 +4,9 @@ LICENSE = "LGPL-2.1-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c"
SRCREV = "dc2c284664757fce6ef8f96f8b3ab667a53ef489"
SRC_URI = "git://github.com/HardySimpson/zlog;branch=master;protocol=https"
SRC_URI = "git://github.com/HardySimpson/zlog;branch=master;protocol=https \
file://0001-CVE-2024-22857-buffer-overflow-patched.patch \
"
S = "${WORKDIR}/git"