aboutsummaryrefslogtreecommitdiff
path: root/src/projections
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@mines-paris.org>2019-04-05 15:41:28 +0200
committerGitHub <noreply@github.com>2019-04-05 15:41:28 +0200
commit0ea2b4e82700ba9aa0ae67ec0ee72ae58bc4f0c9 (patch)
treea602774d5e52071f006b37d59147708a4b57739e /src/projections
parent1e2e512f9a671df504f6f01eee53dc26939b3c0a (diff)
parentf6ba932a8f1d7f0775d4ebe367b2d5faef57461a (diff)
downloadPROJ-0ea2b4e82700ba9aa0ae67ec0ee72ae58bc4f0c9.tar.gz
PROJ-0ea2b4e82700ba9aa0ae67ec0ee72ae58bc4f0c9.zip
Merge pull request #1411 from rouault/ossfuzz_14044_and_all
Ossfuzz 14044 and others
Diffstat (limited to 'src/projections')
-rw-r--r--src/projections/aea.cpp2
-rw-r--r--src/projections/imw_p.cpp14
-rw-r--r--src/projections/krovak.cpp6
-rw-r--r--src/projections/lcc.cpp5
4 files changed, 19 insertions, 8 deletions
diff --git a/src/projections/aea.cpp b/src/projections/aea.cpp
index 8a80c49c..e488ddd9 100644
--- a/src/projections/aea.cpp
+++ b/src/projections/aea.cpp
@@ -182,7 +182,7 @@ static PJ *setup(PJ *P) {
Q->n = (m1 * m1 - m2 * m2) / (ml2 - ml1);
if (Q->n == 0) {
// Not quite, but es is very close to 1...
- return destructor(P, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER);
+ return destructor(P, PJD_ERR_INVALID_ECCENTRICITY);
}
}
Q->ec = 1. - .5 * P->one_es * log((1. - P->e) /
diff --git a/src/projections/imw_p.cpp b/src/projections/imw_p.cpp
index 41882df2..8d675318 100644
--- a/src/projections/imw_p.cpp
+++ b/src/projections/imw_p.cpp
@@ -117,12 +117,16 @@ static PJ_LP e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoidal, inverse */
do {
t = loc_for(lp, P, &yc);
const double denom = t.y - yc;
- if( denom == 0 ) {
- proj_errno_set(P, PJD_ERR_NON_CONVERGENT);
- return proj_coord_error().lp;
+ if( denom != 0 || fabs(t.y - xy.y) > TOL )
+ {
+ if( denom == 0 ) {
+ proj_errno_set(P, PJD_ERR_NON_CONVERGENT);
+ return proj_coord_error().lp;
+ }
+ lp.phi = ((lp.phi - Q->phi_1) * (xy.y - yc) / denom) + Q->phi_1;
}
- lp.phi = ((lp.phi - Q->phi_1) * (xy.y - yc) / denom) + Q->phi_1;
- lp.lam = lp.lam * xy.x / t.x;
+ if( t.x != 0 || fabs(t.x - xy.x) > TOL )
+ lp.lam = lp.lam * xy.x / t.x;
i ++;
} while (i < N_MAX_ITER &&
(fabs(t.x - xy.x) > TOL || fabs(t.y - xy.y) > TOL));
diff --git a/src/projections/krovak.cpp b/src/projections/krovak.cpp
index c30be411..c3f61f3d 100644
--- a/src/projections/krovak.cpp
+++ b/src/projections/krovak.cpp
@@ -222,7 +222,11 @@ PJ *PROJECTION(krovak) {
Q->alpha = sqrt(1. + (P->es * pow(cos(P->phi0), 4)) / (1. - P->es));
u0 = asin(sin(P->phi0) / Q->alpha);
g = pow( (1. + P->e * sin(P->phi0)) / (1. - P->e * sin(P->phi0)) , Q->alpha * P->e / 2. );
- Q->k = tan( u0 / 2. + M_PI_4) / pow (tan(P->phi0 / 2. + M_PI_4) , Q->alpha) * g;
+ double tan_half_phi0_plus_pi_4 = tan(P->phi0 / 2. + M_PI_4);
+ if( tan_half_phi0_plus_pi_4 == 0.0 ) {
+ return pj_default_destructor(P, PJD_ERR_INVALID_ARG);
+ }
+ Q->k = tan( u0 / 2. + M_PI_4) / pow (tan_half_phi0_plus_pi_4 , Q->alpha) * g;
n0 = sqrt(1. - P->es) / (1. - P->es * pow(sin(P->phi0), 2));
Q->n = sin(S0);
Q->rho0 = P->k0 * n0 / tan(S0);
diff --git a/src/projections/lcc.cpp b/src/projections/lcc.cpp
index 55d28b80..8cc743a9 100644
--- a/src/projections/lcc.cpp
+++ b/src/projections/lcc.cpp
@@ -113,7 +113,7 @@ PJ *PROJECTION(lcc) {
Q->n = log(m1 / pj_msfn(sinphi, cos(Q->phi2), P->es));
if (Q->n == 0) {
// Not quite, but es is very close to 1...
- return pj_default_destructor(P, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER);
+ return pj_default_destructor(P, PJD_ERR_INVALID_ECCENTRICITY);
}
const double ml2 = pj_tsfn(Q->phi2, sinphi, P->e);
if( ml2 == 0 ) {
@@ -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) /