From e52ab929670eaa65cc6c0284f24d3c0fa53f6bcc Mon Sep 17 00:00:00 2001 From: Kurt Schwehr Date: Sun, 25 Mar 2018 13:51:58 -0700 Subject: Catch over range lam0 in proj_etmerc.c lam0 of inf caused a nan in the cast to int. Picked +/-1000 for lam0 as a guess for what constitutes reduculously large values. proj_etmerc.c:361:16: runtime error: nan is outside the range of representable values of type 'int' Found with autofuzz: UndefinedBehaviorSanitizer: float-cast-overflow --- src/proj_etmerc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/proj_etmerc.c b/src/proj_etmerc.c index ffb10930..99646d14 100644 --- a/src/proj_etmerc.c +++ b/src/proj_etmerc.c @@ -345,6 +345,10 @@ PJ *PROJECTION(utm) { proj_errno_set(P, PJD_ERR_ELLIPSOID_USE_REQUIRED); return pj_default_destructor(P, ENOMEM); } + if (P->lam0 < -1000.0 || P->lam0 > 1000.0) { + return pj_default_destructor(P, PJD_ERR_INVALID_UTM_ZONE); + } + P->y0 = pj_param (P->ctx, P->params, "bsouth").i ? 10000000. : 0.; P->x0 = 500000.; if (pj_param (P->ctx, P->params, "tzone").i) /* zone input ? */ -- cgit v1.2.3