From 81ee400af413e4b2449213d269c1422b8611e3aa Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 20 Mar 2019 18:25:46 +0100 Subject: 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 --- src/ell_set.cpp | 4 ++++ test/gie/ellipsoid.gie | 3 +++ 2 files changed, 7 insertions(+) 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 -- cgit v1.2.3