Repository navigation
net_io: reject SBS altitude, heading and rate outside their range - #201
Merged
Merged
Conversation
decodeSbsLine() checks fields 12, 14 and 17 with isfinite() and stores them in int members. 1e308 is a finite double but far outside int, so the conversion is undefined: a release build stores INT_MAX, which shows up in aircraft.json as alt_baro and baro_rate 2147483647, and a UBSan build aborts. Headings below 0 or above 360 are accepted the same way. Bound altitude and vertical rate to +-100000 ft / ft/min and the heading to 0..360 degrees, far beyond what a receiver or mlat client reports, and treat an out-of-range field as invalid like the other parse failures. The ground speed field already bounds 0..6000 kt.
wiedehopf
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
decodeSbsLine()accepts fields 12 (baro altitude), 14 (heading) and 17 (vertical rate) when they are finite, and stores altitude and rate inintmembers.1e308is a finite double but far outsideint, so the conversion is undefined.Impact
With
--net-sbs-in-port(or any SBS input/connector), a feeder that sends an out-of-range altitude or vertical rate puts2147483647intoalt_baro/baro_rateinaircraft.json(and into the JSON/VRS outputs), and a UBSan build aborts.1e308also overflows the signed arithmetic inupdateAltitude(). A heading of 361 or -5 is accepted as a valid track. The ground speed field has the same problem for 1e308, which was already bounded to 0..6000 kt.Repro
Before (release build),
aircraft.json:Before (UBSan build):
and with a heading of 361 the aircraft reports
"track": 361.Fix
Require
fabs(tmp) <= 100000for altitude and vertical rate, and0 <= heading <= 360, the same way the ground speed field already requires0..6000kt. An out-of-range field is marked invalid like any other parse failure; the rest of the record is still used.Verification
alt_baroandbaro_rateare absent fromaircraft.json, the aircraft is still tracked, and no sanitizer report appears.35000 ft,-1216 ft/min, heading 90, ground speed 90 kt.