diff options
| author | Even Rouault <even.rouault@mines-paris.org> | 2019-04-19 10:29:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-19 10:29:38 +0200 |
| commit | fb88946ac55fafd25a021e26c151b492efe5fd4c (patch) | |
| tree | caf537535841aee349580bb94a5b5f2fdf766351 /src | |
| parent | cf0a6384741354811f821f1cc63bb7f2b69b9924 (diff) | |
| parent | 3f6c53ccee6062df95c595a0ea5b8cbed7e7f199 (diff) | |
| download | PROJ-fb88946ac55fafd25a021e26c151b492efe5fd4c.tar.gz PROJ-fb88946ac55fafd25a021e26c151b492efe5fd4c.zip | |
Merge pull request #1431 from rouault/ossfuzz_14286_14342
Ossfuzz 14286 14342
Diffstat (limited to 'src')
| -rw-r--r-- | src/projections/isea.cpp | 4 | ||||
| -rw-r--r-- | src/projections/nsper.cpp | 16 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/projections/isea.cpp b/src/projections/isea.cpp index 28510cb0..e8720b27 100644 --- a/src/projections/isea.cpp +++ b/src/projections/isea.cpp @@ -898,6 +898,10 @@ static int isea_hex(struct isea_dgg *g, int tri, quad = isea_ptdi(g, tri, pt, &v); + if( v.x < (INT_MIN >> 4) || v.x > (INT_MAX >> 4) ) + { + throw "Invalid shift"; + } hex->x = ((int)v.x << 4) + quad; hex->y = v.y; diff --git a/src/projections/nsper.cpp b/src/projections/nsper.cpp index a0bb5686..37938924 100644 --- a/src/projections/nsper.cpp +++ b/src/projections/nsper.cpp @@ -96,7 +96,7 @@ static PJ_XY s_forward (PJ_LP lp, PJ *P) { /* Spheroidal, forward */ static PJ_LP s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse */ PJ_LP lp = {0.0,0.0}; struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); - double rh, cosz, sinz; + double rh; if (Q->tilt) { double bm, bq, yt; @@ -108,16 +108,18 @@ static PJ_LP s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse */ xy.y = bq * Q->cg - bm * Q->sg; } rh = hypot(xy.x, xy.y); - if ((sinz = 1. - rh * rh * Q->pfact) < 0.) { - proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); - return lp; - } - sinz = (Q->p - sqrt(sinz)) / (Q->pn1 / rh + rh / Q->pn1); - cosz = sqrt(1. - sinz * sinz); if (fabs(rh) <= EPS10) { lp.lam = 0.; lp.phi = P->phi0; } else { + double cosz, sinz; + sinz = 1. - rh * rh * Q->pfact; + if (sinz < 0.) { + proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); + return lp; + } + sinz = (Q->p - sqrt(sinz)) / (Q->pn1 / rh + rh / Q->pn1); + cosz = sqrt(1. - sinz * sinz); switch (Q->mode) { case OBLIQ: lp.phi = asin(cosz * Q->sinph0 + xy.y * sinz * Q->cosph0 / rh); |
