diff options
| author | Kurt Schwehr <schwehr@google.com> | 2018-05-22 17:17:47 -0700 |
|---|---|---|
| committer | Kurt Schwehr <schwehr@google.com> | 2018-05-22 17:17:47 -0700 |
| commit | 03c4a33755f6c8bba4b97ea7cfd3536d95305014 (patch) | |
| tree | 5805deda2d58241a7a8b6021295d9dd3efef7d50 | |
| parent | 37ebb8f9f0cc5083d22f84433fb2de0fdde8be00 (diff) | |
| download | PROJ-03c4a33755f6c8bba4b97ea7cfd3536d95305014.tar.gz PROJ-03c4a33755f6c8bba4b97ea7cfd3536d95305014.zip | |
Limit the number of round trips to 1 million and check for underflows
Why was fabs applied to ntrips? And why is it parsed as a float?
Also add documentation for roundtrip.
External rst docs do not match this function.
| -rw-r--r-- | src/gie.c | 26 |
1 files changed, 25 insertions, 1 deletions
@@ -705,6 +705,20 @@ static int roundtrip (const char *args) { /***************************************************************************** Check how far we go from the ACCEPTed point when doing successive back/forward transformation pairs. + +Without args, roundtrip defaults to 100 iterations: + + roundtrip + +With one arg, roundtrip will default to a tolerance of T.tolerance: + + roundtrip ntrips + +With two args: + + roundtrip ntrips tolerance + +Always returns 0. ******************************************************************************/ int ntrips; double d, r, ans; @@ -719,7 +733,17 @@ back/forward transformation pairs. } ans = proj_strtod (args, &endp); - ntrips = (int) (endp==args? 100: fabs(ans)); + if (endp==args) { + /* Default to 100 iterations if not args. */ + ntrips = 100; + } else { + if (ans < 1.0 || ans > 1000000.0) { + errmsg (2, "Invalid number of roundtrips: %lf\n", ans); + return another_failing_roundtrip (); + } + ntrips = (int)ans; + } + d = strtod_scaled (endp, 1); d = d==HUGE_VAL? T.tolerance: d; |
