According to the tool's documentation, when '-l standard' is specified,
log would be output to the stdout. But since it's using strncmp(a, b, 10)
to compare the former 10 characters, it will also wrongly detect a filename
starting with a substring 'standard' as stdout.

For example:
$ cxl monitor -l standard.log

User is most likely want to save log to ./standard.log instead of stdout.

Signed-off-by: Li Zhijian <[email protected]>
---
V3: Improve commit log # Dave
V2: commit log updated # Dave
---
 cxl/monitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cxl/monitor.c b/cxl/monitor.c
index f0e3c4c3f45c..179646562187 100644
--- a/cxl/monitor.c
+++ b/cxl/monitor.c
@@ -188,7 +188,7 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx 
*ctx)
        else
                monitor.ctx.log_priority = LOG_INFO;
 
-       if (strncmp(log, "./standard", 10) == 0)
+       if (strcmp(log, "./standard") == 0)
                monitor.ctx.log_fn = log_standard;
        else {
                monitor.ctx.log_file = fopen(log, "a+");
-- 
2.29.2


Reply via email to