diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-03-20 11:46:39 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-03-20 11:46:39 +0100 |
| commit | 20b1fac56fc23950790b2f46761b8308d455daa9 (patch) | |
| tree | ff2dd3fca341a313109ef663f439d8f55e29eb45 | |
| parent | 9ead1bfe5afd7e519fe5f83b6603e5147fa91411 (diff) | |
| download | PROJ-20b1fac56fc23950790b2f46761b8308d455daa9.tar.gz PROJ-20b1fac56fc23950790b2f46761b8308d455daa9.zip | |
sterea: prevent division by zero
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13790
Credit to OSS Fuzz
| -rw-r--r-- | src/projections/sterea.cpp | 7 | ||||
| -rw-r--r-- | test/gie/builtins.gie | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/projections/sterea.cpp b/src/projections/sterea.cpp index b6ebc7b4..964bb588 100644 --- a/src/projections/sterea.cpp +++ b/src/projections/sterea.cpp @@ -53,7 +53,12 @@ static PJ_XY e_forward (PJ_LP lp, PJ *P) { /* Ellipsoidal, forward */ sinc = sin(lp.phi); cosc = cos(lp.phi); cosl = cos(lp.lam); - k = P->k0 * Q->R2 / (1. + Q->sinc0 * sinc + Q->cosc0 * cosc * cosl); + const double denom = 1. + Q->sinc0 * sinc + Q->cosc0 * cosc * cosl; + if( denom == 0.0 ) { + proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION); + return proj_coord_error().xy; + } + k = P->k0 * Q->R2 / denom; xy.x = k * cosc * sin(lp.lam); xy.y = k * (Q->cosc0 * sinc - Q->sinc0 * cosc * cosl); return xy; diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index 32aad873..313d0631 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -4743,6 +4743,8 @@ accept -2 1 expect -223407.810259507 111737.938996443 accept -2 -1 expect -223407.810259507 -111737.938996443 +accept 180 0 +expect failure errno tolerance_condition direction inverse accept 200 100 |
