Skip to content

Commit

Permalink
drivers/sensors/gnss: check invalid nmea statement to avoid parsebuff…
Browse files Browse the repository at this point in the history
…er overflow

Signed-off-by: dongjiuzhu1 <[email protected]>
  • Loading branch information
Donny9 authored and xiaoxiang781216 committed Sep 30, 2024
1 parent 9599302 commit 58d233c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/sensors/gnss_uorb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 58d233c

Please sign in to comment.