forked from nuttx/nuttx-update
drivers/sensors/gnss: check invalid nmea statement to avoid parsebuffer overflow
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
9599302f10
commit
58d233cb42
1 changed files with 9 additions and 2 deletions
|
@ -591,8 +591,15 @@ static void gnss_parse(FAR struct gnss_upperhalf_s *upper,
|
|||
{
|
||||
if (*buffer != '\r' && *buffer != '\n')
|
||||
{
|
||||
upper->parsebuffer[upper->parsenext++] = *buffer;
|
||||
continue;
|
||||
if (upper->parsenext + 1 < GNSS_PARSE_BUFFERSIZE)
|
||||
{
|
||||
upper->parsebuffer[upper->parsenext++] = *buffer;
|
||||
continue;
|
||||
}
|
||||
|
||||
upper->parsebuffer[upper->parsenext] = '\0';
|
||||
snerr("NMEA buffer overflow, invalid statement:%s\n",
|
||||
upper->parsebuffer);
|
||||
}
|
||||
|
||||
upper->parsebuffer[upper->parsenext] = '\0';
|
||||
|
|
Loading…
Reference in a new issue