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 <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-02-23 11:28:59 +08:00 committed by Xiang Xiao
parent 0f8ecc0150
commit 9c30d3bf33

View File

@ -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
}