aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-04-20 17:49:37 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-04-20 17:49:37 +0200
commit318dab0d074a7bfd9d0724e674777aa10422d4e6 (patch)
treefa641e89575500ce248f3c3195b858b3aaf7bdc3
parente1da8e5f6933bfb914dccb26a755a23b5ce9f36f (diff)
downloadPROJ-318dab0d074a7bfd9d0724e674777aa10422d4e6.tar.gz
PROJ-318dab0d074a7bfd9d0724e674777aa10422d4e6.zip
omerc: validate lat_1 and lat_2 to avoid divison by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14384 Credit to OSS Fuzz
-rw-r--r--src/projections/omerc.cpp2
-rw-r--r--test/gie/builtins.gie10
2 files changed, 12 insertions, 0 deletions
diff --git a/src/projections/omerc.cpp b/src/projections/omerc.cpp
index e07c209e..0de3aa7d 100644
--- a/src/projections/omerc.cpp
+++ b/src/projections/omerc.cpp
@@ -154,6 +154,8 @@ PJ *PROJECTION(omerc) {
phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
lam2 = pj_param(P->ctx, P->params, "rlon_2").f;
phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
+ if (fabs(phi1) > M_HALFPI || fabs(phi2) > M_HALFPI)
+ return pj_default_destructor(P, PJD_ERR_LAT_LARGER_THAN_90);
if (fabs(phi1 - phi2) <= TOL ||
(con = fabs(phi1)) <= TOL ||
fabs(con - M_HALFPI) <= TOL ||
diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie
index 235771d5..49b135d9 100644
--- a/test/gie/builtins.gie
+++ b/test/gie/builtins.gie
@@ -4013,6 +4013,16 @@ operation +proj=omerc +lat_1=0.8 +a=6400000 +b=.4
-------------------------------------------------------------------------------
expect failure errno invalid_eccentricity
+-------------------------------------------------------------------------------
+operation +proj=omerc +lat_1=91
+-------------------------------------------------------------------------------
+expect failure errno lat_larger_than_90
+
+-------------------------------------------------------------------------------
+operation +proj=omerc +lat_2=91
+-------------------------------------------------------------------------------
+expect failure errno lat_larger_than_90
+
===============================================================================
Ortelius Oval