From 03b20f848b646c0d37b7357fe2874a6e34975f01 Mon Sep 17 00:00:00 2001 From: "Gary E. Miller" Date: Thu, 27 Sep 2018 19:55:49 -0700 Subject: cgps: try to prevent overflow on large error estimates. --- cgps.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'cgps.c') diff --git a/cgps.c b/cgps.c index b97975fb..1fda727a 100644 --- a/cgps.c +++ b/cgps.c @@ -164,11 +164,17 @@ static char *dop_to_str(double dop) static char *ep_to_str(double ep, double factor, char *units) { static char buf[20]; + double val; if (isfinite(ep) == 0) { return " n/a "; } - (void)snprintf(buf, sizeof(buf), "+/-%5.1f %.8s", ep * factor, units); + val = ep * factor; + if ( 100 <= val ) { + (void)snprintf(buf, sizeof(buf), "+/-%5d %.3s", (int)val, units); + } else { + (void)snprintf(buf, sizeof(buf), "+/-%5.1f %.3s", val, units); + } return buf; } @@ -920,7 +926,7 @@ int main(int argc, char *argv[]) altfactor = METERS_TO_FEET; altunits = "ft"; speedfactor = MPS_TO_KNOTS; - speedunits = "knots"; + speedunits = "kts"; break; case metric: altfactor = 1; -- cgit v1.2.1