From c47f781a9f1e9604f5201e27d046d925d0d48ac4 Mon Sep 17 00:00:00 2001 From: Ali Raza Date: Thu, 29 Feb 2024 11:36:25 +0500 Subject: [PATCH] buffer overflow patched (#251) Thank you for the PR --- src/rule.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rule.c b/src/rule.c index 9326e4b..8c15263 100644 --- a/src/rule.c +++ b/src/rule.c @@ -880,8 +880,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) {