NMEA Satellite Info parser: limit number of sentences


The NMEA GSV message can consist of multiple sentences.
Each sentence can contain the information about up to four visible
satellites.
All the documentation about NMEA mentions that the typical amount
of sentences in a message will be up to 10 (e.g. [0]).

The total number of sentences, as well as the number of the current
sentence, are sent in each sentence. The existing implementation
is using these values, but is not anyhow validating them.

This could lead to interesting results like integer overflow when
calculating the number of satellites in the sentence if the number
of the current sentence was too large.

This patch introduces a hard limit for the total number of sentences
and also makes sure that the current sentence is not larger than
the maximum value.

The suggested limit of 250 sentences potentially means 1000
satellites, which is more than enough in practice. This value is
also small enough to make sure that there will be no overflows
when doing any of the calculations.

Add unit-tests to cover this case.

Since an integer overflow is UB, pick this change down to 6.5.
Do not pick to 5.15, because the entire satelliteinfo parser logic
is slightly different there, and it is also not covered by tests.

[0]: https://gpsd.gitlab.io/gpsd/NMEA.html#_gsv_satellites_in_view

Task-number: QTBUG-146551
Pick-to: 6.11 6.8 6.5
Change-Id: I4b11bd34a0fbc0b787efb34c4372701470063046
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
commit40a15bb3d5a068dd2bdea0c159f153ddb3d00b34
parentb646e87811f790b564f392f6b436cefed7aa9c5e
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeTue, 19 May 2026 08:58:56 +0000