From 8ae2f83174808ac41324c33a749b9cb7ac7eca51 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 16 Apr 2019 22:02:26 +0200 Subject: omerc: avoid division by zero Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14279 Credit to OSS Fuzz --- src/projections/omerc.cpp | 4 ++++ test/gie/builtins.gie | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/projections/omerc.cpp b/src/projections/omerc.cpp index c0278043..e07c209e 100644 --- a/src/projections/omerc.cpp +++ b/src/projections/omerc.cpp @@ -201,6 +201,10 @@ PJ *PROJECTION(omerc) { L = pow(pj_tsfn(phi2, sin(phi2), P->e), Q->B); F = Q->E / H; p = (L - H) / (L + H); + if( p == 0 ) { + // Not quite, but es is very close to 1... + return pj_default_destructor(P, PJD_ERR_INVALID_ECCENTRICITY); + } J = Q->E * Q->E; J = (J - L * H) / (J + L * H); if ((con = lam1 - lam2) < -M_PI) diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index 8e82979e..631767a3 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -4005,6 +4005,11 @@ operation +proj=omerc +lat_1=0.1 +a=6400000 +b=1 ------------------------------------------------------------------------------- expect failure errno invalid_eccentricity +------------------------------------------------------------------------------- +operation +proj=omerc +lat_1=0.8 +a=6400000 +b=.4 +------------------------------------------------------------------------------- +expect failure errno invalid_eccentricity + =============================================================================== Ortelius Oval -- cgit v1.2.3