mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
trace: fix trace dump crash
After thread switching is triggered in an interrupt, two notes will be printed. If the buffer of 256 is not enough, it will cause overflow. Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
This commit is contained in:
parent
9c51919a1a
commit
bcbd092d3e
1 changed files with 7 additions and 2 deletions
|
|
@ -67,7 +67,7 @@ static void note_ioctl(int cmd, unsigned long arg)
|
|||
|
||||
int trace_dump(FAR FILE *out)
|
||||
{
|
||||
uint8_t tracedata[UCHAR_MAX];
|
||||
uint8_t tracedata[1024];
|
||||
int ret;
|
||||
int fd;
|
||||
|
||||
|
|
@ -85,7 +85,12 @@ int trace_dump(FAR FILE *out)
|
|||
while (1)
|
||||
{
|
||||
ret = read(fd, tracedata, sizeof tracedata);
|
||||
if (ret <= 0)
|
||||
if (ret < 0 || ret > sizeof(tracedata))
|
||||
{
|
||||
fprintf(stderr, "trace: read error: %d, errno:%d\n", ret, errno);
|
||||
continue;
|
||||
}
|
||||
else if (ret == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue