diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-04-05 13:25:17 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-04-05 13:25:17 +0200 |
| commit | 97de772e16281fad460a1469c34cd37ff42bcefb (patch) | |
| tree | fe29a1535379858a5d60f2c479a8297214d037f5 | |
| parent | 3aed84243a8188b54d19d7e9c26028796eb398b0 (diff) | |
| download | PROJ-97de772e16281fad460a1469c34cd37ff42bcefb.tar.gz PROJ-97de772e16281fad460a1469c34cd37ff42bcefb.zip | |
lcc: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14058
Credit to OSS Fuzz
| -rw-r--r-- | src/projections/lcc.cpp | 3 | ||||
| -rw-r--r-- | test/gie/builtins.gie | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/projections/lcc.cpp b/src/projections/lcc.cpp index 3e93f98c..8cc743a9 100644 --- a/src/projections/lcc.cpp +++ b/src/projections/lcc.cpp @@ -125,6 +125,9 @@ PJ *PROJECTION(lcc) { Q->rho0 *= (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. : pow(pj_tsfn(P->phi0, sin(P->phi0), P->e), Q->n); } else { + if( fabs(cosphi) < EPS10 || fabs(cos(Q->phi2)) < EPS10 ) { + return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); + } if (secant) Q->n = log(cosphi / cos(Q->phi2)) / log(tan(M_FORTPI + .5 * Q->phi2) / diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index 6976aaca..e5bec322 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -2720,6 +2720,16 @@ operation +proj=lcc +ellps=GRS80 +lat_1=90 +lat_2=90 ------------------------------------------------------------------------------- expect failure errno lat_1_or_2_zero_or_90 +------------------------------------------------------------------------------- +operation +proj=lcc +ellps=sphere +lat_1=0 +lat_2=90 +------------------------------------------------------------------------------- +expect failure errno lat_1_or_2_zero_or_90 + +------------------------------------------------------------------------------- +operation +proj=lcc +ellps=sphere +lat_1=90 +lat_2=0 +------------------------------------------------------------------------------- +expect failure errno lat_1_or_2_zero_or_90 + =============================================================================== Lambert Conformal Conic Alternative Conic, Sph&Ell |
