Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eqdc: avoid floating point division by zero in non-nominal case. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=52879 #3415

Merged
merged 1 commit into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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