diff options
| author | Even Rouault <even.rouault@mines-paris.org> | 2019-04-01 15:23:46 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-01 15:23:46 +0200 |
| commit | 0fcfcd20688dbadf01df83fdeaa038346f45c163 (patch) | |
| tree | 2f451eec1a941483d85ccac2071eecd8604be041 | |
| parent | a4eb9f255d3f08985fc9360660202e3b00cad958 (diff) | |
| parent | ff1e495525969352f83507950dd4e1fd3cec69c2 (diff) | |
| download | PROJ-0fcfcd20688dbadf01df83fdeaa038346f45c163.tar.gz PROJ-0fcfcd20688dbadf01df83fdeaa038346f45c163.zip | |
Merge pull request #1396 from rouault/ossfuzz_13947_13948
Ossfuzz 13947 13948
| -rw-r--r-- | src/conversions/unitconvert.cpp | 24 | ||||
| -rw-r--r-- | src/projections/tpeqd.cpp | 4 | ||||
| -rw-r--r-- | test/gie/builtins.gie | 8 | ||||
| -rw-r--r-- | test/gie/unitconvert.gie | 24 |
4 files changed, 46 insertions, 14 deletions
diff --git a/src/conversions/unitconvert.cpp b/src/conversions/unitconvert.cpp index e436a222..7ef07311 100644 --- a/src/conversions/unitconvert.cpp +++ b/src/conversions/unitconvert.cpp @@ -472,11 +472,11 @@ PJ *CONVERSION(unitconvert,0) { if (f != 0.0) { proj_log_debug(P, "xy_in unit: %s", normalized_name); } else { - if ( (f = pj_param (P->ctx, P->params, "dxy_in").f) == 0.0) + f = pj_param (P->ctx, P->params, "dxy_in").f; + if (f == 0.0 || 1.0 / f == 0.0) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); } - if (f != 0.0) - Q->xy_factor *= f; + Q->xy_factor = f; if (normalized_name != nullptr && strcmp(normalized_name, "Radian") == 0) P->left = PJ_IO_UNITS_RADIANS; } @@ -487,11 +487,11 @@ PJ *CONVERSION(unitconvert,0) { if (f != 0.0) { proj_log_debug(P, "xy_out unit: %s", normalized_name); } else { - if ( (f = pj_param (P->ctx, P->params, "dxy_out").f) == 0.0) + f = pj_param (P->ctx, P->params, "dxy_out").f; + if (f == 0.0 || 1.0 / f == 0.0) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); } - if (f != 0.0) - Q->xy_factor /= f; + Q->xy_factor /= f; if (normalized_name != nullptr && strcmp(normalized_name, "Radian") == 0) P->right= PJ_IO_UNITS_RADIANS; } @@ -508,11 +508,11 @@ PJ *CONVERSION(unitconvert,0) { if (f != 0.0) { proj_log_debug(P, "z_in unit: %s", normalized_name); } else { - if ( (f = pj_param (P->ctx, P->params, "dz_in").f) == 0.0) + f = pj_param (P->ctx, P->params, "dz_in").f; + if (f == 0.0 || 1.0 / f == 0.0) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); } - if (f != 0.0) - Q->z_factor *= f; + Q->z_factor = f; } if ((name = pj_param (P->ctx, P->params, "sz_out").s) != nullptr) { @@ -521,11 +521,11 @@ PJ *CONVERSION(unitconvert,0) { if (f != 0.0) { proj_log_debug(P, "z_out unit: %s", normalized_name); } else { - if ( (f = pj_param (P->ctx, P->params, "dz_out").f) == 0.0) + f = pj_param (P->ctx, P->params, "dz_out").f; + if (f == 0.0 || 1.0 / f == 0.0) return pj_default_destructor(P, PJD_ERR_UNKNOWN_UNIT_ID); } - if (f != 0.0) - Q->z_factor /= f; + Q->z_factor /= f; } if( z_in_is_linear >= 0 && z_out_is_linear >= 0 && diff --git a/src/projections/tpeqd.cpp b/src/projections/tpeqd.cpp index 20921de4..9904bb8c 100644 --- a/src/projections/tpeqd.cpp +++ b/src/projections/tpeqd.cpp @@ -87,6 +87,10 @@ PJ *PROJECTION(tpeqd) { Q->sc = Q->sp1 * Q->cp2; Q->ccs = Q->cp1 * Q->cp2 * sin(Q->dlam2); Q->z02 = aacos(P->ctx, Q->sp1 * Q->sp2 + Q->cp1 * Q->cp2 * cos (Q->dlam2)); + if( Q->z02 == 0.0 ) { + // Actually happens when both lat_1 = lat_2 and |lat_1| = 90 + return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90); + } Q->hz0 = .5 * Q->z02; A12 = atan2(Q->cp2 * sin (Q->dlam2), Q->cp1 * Q->sp2 - Q->sp1 * Q->cp2 * cos (Q->dlam2)); diff --git a/test/gie/builtins.gie b/test/gie/builtins.gie index c8eb3a11..2cc44632 100644 --- a/test/gie/builtins.gie +++ b/test/gie/builtins.gie @@ -5243,7 +5243,7 @@ Two Point Equidistant =============================================================================== ------------------------------------------------------------------------------- -operation +proj=tpeqd +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5 +operation +proj=tpeqd +ellps=GRS80 +lat_1=0.5 +lat_2=2 ------------------------------------------------------------------------------- tolerance 0.18 mm accept 2 1 @@ -5266,7 +5266,7 @@ accept -200 -100 expect 0.000898554 1.248203369 ------------------------------------------------------------------------------- -operation +proj=tpeqd +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5 +operation +proj=tpeqd +a=6400000 +lat_1=0.5 +lat_2=2 ------------------------------------------------------------------------------- tolerance 0.1 mm accept 2 1 @@ -5288,6 +5288,10 @@ expect -0.000895485 1.248209507 accept -200 -100 expect 0.000895485 1.248209507 +------------------------------------------------------------------------------- +operation +proj=tpeqd +a=6400000 +lat_1=90 +lat_2=90 +lon_1=0 +lon_2=1 +------------------------------------------------------------------------------- +expect failure =============================================================================== Tilted perspective diff --git a/test/gie/unitconvert.gie b/test/gie/unitconvert.gie index 2e06fe72..f763959b 100644 --- a/test/gie/unitconvert.gie +++ b/test/gie/unitconvert.gie @@ -43,4 +43,28 @@ operation proj=unitconvert z_in=rad z_out=m accept 1 1 1 1 expect failure +operation proj=unitconvert xy_in=0 +expect failure + +operation proj=unitconvert xy_out=0 +expect failure + +operation proj=unitconvert xy_in=1e400 +expect failure + +operation proj=unitconvert xy_out=1e400 +expect failure + +operation proj=unitconvert z_in=0 +expect failure + +operation proj=unitconvert z_out=0 +expect failure + +operation proj=unitconvert z_in=1e400 +expect failure + +operation proj=unitconvert z_out=1e400 +expect failure + </gie> |
