From 9c30d3bf3360be0aebda615f450205172e2d29fb Mon Sep 17 00:00:00 2001 From: chao an Date: Thu, 23 Feb 2023 11:28:59 +0800 Subject: [PATCH] procfs/meminfo: skip invalid character before memdump In the case of echo characters, atoi will mistake CRLF as a digit character and convert it to 0 Signed-off-by: chao an --- fs/procfs/fs_procfsmeminfo.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/procfs/fs_procfsmeminfo.c b/fs/procfs/fs_procfsmeminfo.c index fbdca5d294b..a7703575952 100644 --- a/fs/procfs/fs_procfsmeminfo.c +++ b/fs/procfs/fs_procfsmeminfo.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -523,6 +524,11 @@ static ssize_t memdump_write(FAR struct file *filep, FAR const char *buffer, break; #if CONFIG_MM_BACKTRACE >= 0 default: + if (!isdigit(buffer[0])) + { + return buflen; + } + pid = atoi(buffer); #endif }