38 lines
1.1 KiB
Diff
38 lines
1.1 KiB
Diff
From 99bc5eb28297945c496e8fb0d282e108978c22e7 Mon Sep 17 00:00:00 2001
|
|
From: Yang Shen <shenyang39@huawei.com>
|
|
Date: Mon, 20 Nov 2023 15:21:59 +0800
|
|
Subject: [PATCH 83/85] uadk: wd - fix fscanf infinite loop
|
|
|
|
UADK supports registration of log to the rsyslog service.
|
|
So it will read the rsyslog.conf to user's log level.
|
|
Here use '%[^\n ] ' to divided the lines in file into
|
|
words to analysis.
|
|
|
|
But there is a problem if the first line in the file is
|
|
'\n'. The fscanf will return 0 and always read the first
|
|
line, which makes a infinite loop.
|
|
|
|
Add a whitespace before '%[^\n ] ' to filter the unintended '\n'.
|
|
|
|
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
|
---
|
|
wd.c | 2 +-
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
|
diff --git a/wd.c b/wd.c
|
|
index ddde38d..e88c993 100644
|
|
--- a/wd.c
|
|
+++ b/wd.c
|
|
@@ -79,7 +79,7 @@ static void wd_parse_log_level(void)
|
|
goto close_file;
|
|
}
|
|
|
|
- while (fscanf(in_file, "%[^\n ] ", file_contents) != EOF) {
|
|
+ while (fscanf(in_file, " %[^\n ] ", file_contents) != EOF) {
|
|
if (!strcmp("local5.debug", file_contents))
|
|
log_debug = true;
|
|
else if (!strcmp("local5.info", file_contents))
|
|
--
|
|
2.25.1
|
|
|