Skip to content

Commit

Permalink
Merge pull request #3415 from rouault/fix_ossfuzz_52879
Browse files Browse the repository at this point in the history
eqdc: avoid floating point division by zero in non-nominal case. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52879
  • Loading branch information
rouault authored Oct 30, 2022
2 parents b655125 + 586ef0f commit 9f4b479
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/projections/eqdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,12 @@ PJ *PROJECTION(eqdc) {
if (secant) { /* secant cone */
sinphi = sin(Q->phi2);
cosphi = cos(Q->phi2);
Q->n = (m1 - pj_msfn(sinphi, cosphi, P->es)) /
(pj_mlfn(Q->phi2, sinphi, cosphi, Q->en) - ml1);
const double ml2 = pj_mlfn(Q->phi2, sinphi, cosphi, Q->en);
if (ml1 == ml2) {
proj_log_error(P, _("Eccentricity too close to 1"));
return destructor(P, PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE);
}
Q->n = (m1 - pj_msfn(sinphi, cosphi, P->es)) / (ml2 - ml1);
if (Q->n == 0) {
// Not quite, but es is very close to 1...
proj_log_error(P, _("Invalid value for eccentricity"));
Expand Down
3 changes: 3 additions & 0 deletions test/gie/builtins.gie
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,9 @@ expect failure errno invalid_op_illegal_arg_value
operation +proj=eqdc +R=1 +lat_1=1e-9
expect failure errno invalid_op_illegal_arg_value

operation +proj=eqdc +lat_1=1 +ellps=GRS80 +b=.1
expect failure errno invalid_op_illegal_arg_value

===============================================================================
# Euler
# Conic, Sph
Expand Down

0 comments on commit 9f4b479

Please sign in to comment.