diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2017-05-23 19:32:41 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2017-05-23 19:33:12 +0200 |
| commit | 9ebed249a6c8957b345396f6085090f7d2cd0e47 (patch) | |
| tree | d6a327f6807d4349d0ba317b52ef4c9cbf96d2a6 /src/pj_init.c | |
| parent | b4fade26b674c3f50b2b219cda67448dad1a5885 (diff) | |
| download | PROJ-9ebed249a6c8957b345396f6085090f7d2cd0e47.tar.gz PROJ-9ebed249a6c8957b345396f6085090f7d2cd0e47.zip | |
Avoid potentially very long loop when normalizing longitudes around long_wrap_center
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1809
Credit to OSS Fuzz
Diffstat (limited to 'src/pj_init.c')
| -rw-r--r-- | src/pj_init.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/pj_init.c b/src/pj_init.c index fefcb8fa..6568033f 100644 --- a/src/pj_init.c +++ b/src/pj_init.c @@ -559,7 +559,16 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { /* longitude center for wrapping */ PIN->is_long_wrap_set = pj_param(ctx, start, "tlon_wrap").i; if (PIN->is_long_wrap_set) + { PIN->long_wrap_center = pj_param(ctx, start, "rlon_wrap").f; + /* Don't accept excessive values otherwise we might perform badly */ + /* when correcting longitudes around it */ + if( !(fabs(PIN->long_wrap_center) < 10 * M_TWOPI) ) + { + pj_ctx_set_errno( ctx, -14 ); + goto bum_call; + } + } /* axis orientation */ if( (pj_param(ctx, start,"saxis").s) != NULL ) @@ -584,10 +593,6 @@ pj_init_ctx(projCtx ctx, int argc, char **argv) { strcpy( PIN->axis, axis_arg ); } - PIN->is_long_wrap_set = pj_param(ctx, start, "tlon_wrap").i; - if (PIN->is_long_wrap_set) - PIN->long_wrap_center = pj_param(ctx, start, "rlon_wrap").f; - /* central meridian */ PIN->lam0=pj_param(ctx, start, "rlon_0").f; |
