diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-04-11 00:21:24 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-04-11 00:21:24 +0200 |
| commit | c1e730312965831e6b9c2093677a67716c198622 (patch) | |
| tree | b90bd6f8e54a2f983d1937622de467c80ed49357 | |
| parent | 00dffd7ace356d7cb39e2c515237d4351f5b5666 (diff) | |
| download | PROJ-c1e730312965831e6b9c2093677a67716c198622.tar.gz PROJ-c1e730312965831e6b9c2093677a67716c198622.zip | |
omerc: avoid division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14138
Credit to OSS Fuzz
| -rw-r--r-- | src/projections/omerc.cpp | 7 | ||||
| -rw-r--r-- | test/gie/builtins.gie | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/projections/omerc.cpp b/src/projections/omerc.cpp index 4d78fbef..c0278043 100644 --- a/src/projections/omerc.cpp +++ b/src/projections/omerc.cpp @@ -209,8 +209,11 @@ PJ *PROJECTION(omerc) { lam2 += M_TWOPI; P->lam0 = adjlon(.5 * (lam1 + lam2) - atan( J * tan(.5 * Q->B * (lam1 - lam2)) / p) / Q->B); - gamma0 = atan(2. * sin(Q->B * adjlon(lam1 - P->lam0)) / - (F - 1. / F)); + const double denom = F - 1. / F; + if( denom == 0 ) { + return pj_default_destructor(P, PJD_ERR_INVALID_ECCENTRICITY); + } + gamma0 = atan(2. * sin(Q->B * adjlon(lam1 - P->lam0)) / denom); gamma = alpha_c = aasin(P->ctx, D * sin(gamma0)); } Q->singam = sin(gamma0); diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index bbaca7ba..63766e79 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -3967,6 +3967,11 @@ operation +proj=omerc +R=1 +alpha=0 +lat_0=90 ------------------------------------------------------------------------------- expect failure errno lat_0_or_alpha_eq_90 +------------------------------------------------------------------------------- +operation +proj=omerc +lat_1=0.1 +a=6400000 +b=1 +------------------------------------------------------------------------------- +expect failure errno invalid_eccentricity + =============================================================================== Ortelius Oval |
