aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-03-20 18:25:46 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-03-20 18:25:46 +0100
commit81ee400af413e4b2449213d269c1422b8611e3aa (patch)
tree9ad751dc969e6cebeff5ceb1ff6b14ec9638760e
parent61166380276a0e99b980dfdc6b43ea4656846c08 (diff)
downloadPROJ-81ee400af413e4b2449213d269c1422b8611e3aa.tar.gz
PROJ-81ee400af413e4b2449213d269c1422b8611e3aa.zip
pj_calc_ellipsoid_params(): reject f=1
To avoid division by zero of b. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13830 Credit to OSS Fuzz
-rw-r--r--src/ell_set.cpp4
-rw-r--r--test/gie/ellipsoid.gie3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/ell_set.cpp b/src/ell_set.cpp
index 386b4f46..d0714bee 100644
--- a/src/ell_set.cpp
+++ b/src/ell_set.cpp
@@ -542,6 +542,10 @@ int pj_calc_ellipsoid_params (PJ *P, double a, double es) {
/* flattening */
if (0==P->f)
P->f = 1 - cos (P->alpha); /* = 1 - sqrt (1 - PIN->es); */
+ if (P->f == 1.0) {
+ pj_ctx_set_errno( P->ctx, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER);
+ return PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER;
+ }
P->rf = P->f != 0.0 ? 1.0/P->f: HUGE_VAL;
/* second flattening */
diff --git a/test/gie/ellipsoid.gie b/test/gie/ellipsoid.gie
index 2a7bdd60..8099cfbd 100644
--- a/test/gie/ellipsoid.gie
+++ b/test/gie/ellipsoid.gie
@@ -143,6 +143,9 @@ expect failure errno eccentricity_is_one
operation proj=utm zone=32 ellps=GRS80 b=0
expect failure errno eccentricity_is_one
+operation proj=utm zone=32 ellps=GRS80 f=1
+expect failure errno eccentricity_is_one
+
operation proj=utm zone=32 ellps=GRS80 b=6000000
accept 12 55
expect 699293.0880 5674591.5295