diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-03-14 23:07:29 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-03-14 23:07:29 +0100 |
| commit | fde6150b61aa225bb960d46f1611c82bf81315b3 (patch) | |
| tree | b7c2741163c58245a60242900111f59028667ae3 /src/ell_set.cpp | |
| parent | 5dc01e985e86b441ba2a671b712d3b211c8a2b33 (diff) | |
| download | PROJ-fde6150b61aa225bb960d46f1611c82bf81315b3.tar.gz PROJ-fde6150b61aa225bb960d46f1611c82bf81315b3.zip | |
Reject eccentricity values larger than one
Valid eccentricity should be between 0 (included) or 1 (excluded)
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13665
Credit to OSS Fuzz
Diffstat (limited to 'src/ell_set.cpp')
| -rw-r--r-- | src/ell_set.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/ell_set.cpp b/src/ell_set.cpp index 4c9fc892..71746895 100644 --- a/src/ell_set.cpp +++ b/src/ell_set.cpp @@ -280,8 +280,8 @@ static int ellps_shape (PJ *P) { P->es = pj_atof (pj_param_value (par)); if (HUGE_VAL==P->es) return proj_errno_set (P, PJD_ERR_INVALID_ARG); - if (1==P->es) - return proj_errno_set (P, PJD_ERR_ECCENTRICITY_IS_ONE); + if (P->es >= 1) + return proj_errno_set (P, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER); break; /* eccentricity, e */ @@ -291,8 +291,8 @@ static int ellps_shape (PJ *P) { return proj_errno_set (P, PJD_ERR_INVALID_ARG); if (0==P->e) return proj_errno_set (P, PJD_ERR_INVALID_ARG); - if (1==P->e) - return proj_errno_set (P, PJD_ERR_ECCENTRICITY_IS_ONE); + if (P->e >= 1) + return proj_errno_set (P, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER); P->es = P->e * P->e; break; @@ -301,8 +301,8 @@ static int ellps_shape (PJ *P) { P->b = pj_atof (pj_param_value (par)); if (HUGE_VAL==P->b) return proj_errno_set (P, PJD_ERR_INVALID_ARG); - if (0==P->b) - return proj_errno_set (P, PJD_ERR_ECCENTRICITY_IS_ONE); + if (P->b <= 0) + return proj_errno_set (P, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER); if (P->b==P->a) break; P->f = (P->a - P->b) / P->a; @@ -556,8 +556,8 @@ int pj_calc_ellipsoid_params (PJ *P, double a, double es) { P->one_es = 1. - P->es; if (P->one_es == 0.) { - pj_ctx_set_errno( P->ctx, PJD_ERR_ECCENTRICITY_IS_ONE); - return PJD_ERR_ECCENTRICITY_IS_ONE; + pj_ctx_set_errno( P->ctx, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER); + return PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER; } P->rone_es = 1./P->one_es; @@ -712,6 +712,10 @@ bomb: pj_ctx_set_errno(ctx, PJD_ERR_ES_LESS_THAN_ZERO); return 1; } + if (*es >= 1.) { + pj_ctx_set_errno(ctx, PJD_ERR_ECCENTRICITY_IS_ONE_OR_GREATER); + return 1; + } if (*a <= 0.) { pj_ctx_set_errno(ctx, PJD_ERR_MAJOR_AXIS_NOT_GIVEN); return 1; |
