[hamradio-commits] [dump1090] 326/373: Reject out-of-range latitudes when doing CPR decoding.

Matthew Ernisse mernisse-guest at moszumanska.debian.org
Thu Oct 23 14:58:32 UTC 2014


This is an automated email from the git hooks/post-receive script.

mernisse-guest pushed a commit to branch backport
in repository dump1090.

commit e5b3572e8b27651b207be4f27a2fbb44bdce849a
Author: Oliver Jowett <oliver at mutability.co.uk>
Date:   Thu Sep 25 15:49:39 2014 +0100

    Reject out-of-range latitudes when doing CPR decoding.
    
    If a CPR message with an undetected error is received this can produce out-of-range results for latitude.
    e.g. even latitude of 78000, odd latitude of 0 produces a latitude index j=35 and rlat0 = 213.
---
 mode_s.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/mode_s.c b/mode_s.c
index 34ddec1..3dc2806 100644
--- a/mode_s.c
+++ b/mode_s.c
@@ -2053,6 +2053,9 @@ void decodeCPR(struct aircraft *a, int fflag, int surface) {
         if (rlat1 >= 270) rlat1 -= 360;
     }
 
+    // Check to see that the latitude is in range: -90 .. +90
+    if (rlat0 < -90 || rlat0 > 90 || rlat1 < -90 || rlat1 > 90) return;
+
     // Check that both are in the same latitude zone, or abort.
     if (cprNLFunction(rlat0) != cprNLFunction(rlat1)) return;
 
@@ -2129,6 +2132,12 @@ int decodeCPRrelative(struct aircraft *a, int fflag, int surface) {
     rlat = AirDlat * (j + lat/131072);
     if (rlat >= 270) rlat -= 360;
 
+    // Check to see that the latitude is in range: -90 .. +90
+    if (rlat < -90 || rlat > 90) {
+        a->bFlags &= ~MODES_ACFLAGS_LATLON_REL_OK; // This will cause a quick exit next time if no global has been done
+        return (-1);                               // Time to give up - Latitude error
+    }
+
     // Check to see that answer is reasonable - ie no more than 1/2 cell away 
     if (fabs(rlat - a->lat) > (AirDlat/2)) {
         a->bFlags &= ~MODES_ACFLAGS_LATLON_REL_OK; // This will cause a quick exit next time if no global has been done

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git



More information about the pkg-hamradio-commits mailing list