diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-03-24 16:50:52 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-03-24 16:50:52 +0100 |
| commit | ad889fc63abd2b1352e107c947ed589108cc7bc0 (patch) | |
| tree | 98ea50cb7435b7e4919306c4752b442a79054c18 /src/projections/lcc.cpp | |
| parent | e658bbc00a11ac1599198b148144145ba2917f56 (diff) | |
| download | PROJ-ad889fc63abd2b1352e107c947ed589108cc7bc0.tar.gz PROJ-ad889fc63abd2b1352e107c947ed589108cc7bc0.zip | |
lcc: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13892
Credit to OSS Fuzz
Diffstat (limited to 'src/projections/lcc.cpp')
| -rw-r--r-- | src/projections/lcc.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/projections/lcc.cpp b/src/projections/lcc.cpp index 5eee0d14..55d28b80 100644 --- a/src/projections/lcc.cpp +++ b/src/projections/lcc.cpp @@ -105,6 +105,9 @@ PJ *PROJECTION(lcc) { m1 = pj_msfn(sinphi, cosphi, P->es); ml1 = pj_tsfn(Q->phi1, sinphi, P->e); + if( ml1 == 0 ) { + return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); + } if (secant) { /* secant cone */ sinphi = sin(Q->phi2); Q->n = log(m1 / pj_msfn(sinphi, cos(Q->phi2), P->es)); @@ -112,7 +115,11 @@ PJ *PROJECTION(lcc) { // Not quite, but es is very close to 1... return pj_default_destructor(P, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER); } - Q->n /= log(ml1 / pj_tsfn(Q->phi2, sinphi, P->e)); + const double ml2 = pj_tsfn(Q->phi2, sinphi, P->e); + if( ml2 == 0 ) { + return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); + } + Q->n /= log(ml1 / ml2); } Q->c = (Q->rho0 = m1 * pow(ml1, -Q->n) / Q->n); Q->rho0 *= (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. : |
