This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 9c30d3bf33 procfs/meminfo: skip invalid character before memdump
9c30d3bf33 is described below

commit 9c30d3bf3360be0aebda615f450205172e2d29fb
Author: chao an <anc...@xiaomi.com>
AuthorDate: Thu Feb 23 11:28:59 2023 +0800

    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 <anc...@xiaomi.com>
---
 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 fbdca5d294..a770357595 100644
--- a/fs/procfs/fs_procfsmeminfo.c
+++ b/fs/procfs/fs_procfsmeminfo.c
@@ -36,6 +36,7 @@
 #include <assert.h>
 #include <errno.h>
 #include <debug.h>
+#include <ctype.h>
 
 #include <nuttx/kmalloc.h>
 #include <nuttx/pgalloc.h>
@@ -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
     }

Reply via email to