gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] wsg_separation Issue


From: Gary E. Miller
Subject: Re: [gpsd-dev] wsg_separation Issue
Date: Sat, 5 May 2012 17:13:57 -0700

Yo Beat!

On Sat, 05 May 2012 23:23:13 +0200
Beat Bolli <address@hidden> wrote:

> On 05.05.12 21:38, Gary E. Miller wrote:
> > On Fri, 4 May 2012 09:51:38 -0400
> > "Bywater, Rick (SA-1)" <address@hidden> wrote:
> > 
> >> I was running Coverity on gpsd-2.39 and it complained about an
> >> array-bounds issue in geoid.c in the function wsg84_separation.

> The current code is still wrong IMO:
> 
>     ilat = (int)floor((90. + lat) / 10);
>     ilon = (int)floor((180. + lon) / 10);
> 
>     /* sanity checks to prevent segfault on bad data */
>     if ((ilat > 90) || (ilat < -90)) {
>         return 0.0;
>     }
>     if ((ilon > 180) || (ilon < -180)) {
>         return 0.0;
>     }
> 
> ilat and ilon are offset so as to be >= 0, but the subsequent test
> checks the original degree range without offset or divisor. Checking
> lat and lon above the i{lat,lon} calculation should work.

Seems to me that keeping the sanity test on the integer, rather than, 
the float, is the way to go.  So I think you are suggesting the test
should be:

     if ((ilat > 18) || (ilat < 0)) {
         return 0.0;
     }
     if ((ilon > 36) || (ilon < 0)) {
         return 0.0;
     }

Do I have it right?


RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701
        address@hidden  Tel:+1(541)382-8588

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]