[Top][All Lists]
[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: |
Sun, 6 May 2012 13:17:07 -0700 |
Yo Beat!
I like it. Patch is now in git head.
On Sun, 06 May 2012 14:14:10 +0200
Beat Bolli <address@hidden> wrote:
> On 06.05.12 02:13, Gary E. Miller wrote:
> > 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?
>
> I'd reuse the GEOID_ROW and GEOID_COL constants and merge the two ifs:
>
> /* sanity checks to prevent segfault on bad data */
> if ((ilat >= GEOID_ROW) || (ilat < 0) ||
> (ilon >= GEOID_COL) || (ilon < 0))
> return 0.0;
>
> But other than that, it looks fine.
>
> Regards,
> Beat
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701
address@hidden Tel:+1(541)382-8588
signature.asc
Description: PGP signature
Re: [gpsd-dev] wsg_separation Issue, Eric S. Raymond, 2012/05/06
- Re: [gpsd-dev] wsg_separation Issue, Bywater, Rick (SA-1), 2012/05/07
- Re: [gpsd-dev] wsg_separation Issue, Eric S. Raymond, 2012/05/08
- Re: [gpsd-dev] wsg_separation Issue, Bywater, Rick (SA-1), 2012/05/09
- Re: [gpsd-dev] wsg_separation Issue, Dave Hart, 2012/05/09
- Re: [gpsd-dev] wsg_separation Issue, Eric S. Raymond, 2012/05/10
- Re: [gpsd-dev] wsg_separation Issue, Bywater, Rick (SA-1), 2012/05/10
- Re: [gpsd-dev] wsg_separation Issue, Eric S. Raymond, 2012/05/09