1
0
Fork 0
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:
dongjiuzhu1 2024-09-29 21:00:10 +08:00 committed by Xiang Xiao
parent 9599302f10
commit 58d233cb42

View file

@ -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';