mirror of
https://github.com/apache/nuttx.git
synced 2026-08-18 11:41:51 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user