From 44fc7dda9fc411f7c2f052c2271d563bc52f2518 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 15 Mar 2019 20:17:28 +0100 Subject: ellps_spherification(): detect invalid semi-major axis value Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=12909 Credit to OSS Fuzz --- src/ell_set.cpp | 4 ++++ test/gie/ellipsoid.gie | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/ell_set.cpp b/src/ell_set.cpp index 71746895..386b4f46 100644 --- a/src/ell_set.cpp +++ b/src/ell_set.cpp @@ -399,6 +399,10 @@ static int ellps_spherification (PJ *P) { break; } + if (P->a <= 0.) { + return proj_errno_set(P, PJD_ERR_MAJOR_AXIS_NOT_GIVEN); + } + /* Clean up the ellipsoidal parameters to reflect the sphere */ P->es = P->e = P->f = 0; P->rf = HUGE_VAL; diff --git a/test/gie/ellipsoid.gie b/test/gie/ellipsoid.gie index 2a6d02a5..2a7bdd60 100644 --- a/test/gie/ellipsoid.gie +++ b/test/gie/ellipsoid.gie @@ -67,6 +67,9 @@ expect failure errno major_axis_not_given operation proj=merc +R=0 expect failure errno major_axis_not_given +operation +proj=merc +R_a +a=2 +f=2 +expect failure errno major_axis_not_given + operation expect failure operation cobra -- cgit v1.2.3