Skip to content

Commit

Permalink
Disallow +s=0 when in 4-param. mode.
Browse files Browse the repository at this point in the history
Avoids zero-division in PJ_helmert.c

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1956

Credit to OSS-Fuzz.
  • Loading branch information
kbevers committed Jun 1, 2017
1 parent c3603d7 commit 37369f2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/PJ_helmert.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,15 @@ PJ *PROJECTION(helmert) {
if (pj_param (P->ctx, P->params, "ttheta").i) {
Q->theta_0 = pj_param (P->ctx, P->params, "dtheta").f * ARCSEC_TO_RAD;
Q->fourparam = 1;
Q->scale_0 = 1.0; /* default scale for the 4-param shift */
}

/* Scale */
if (pj_param (P->ctx, P->params, "ts").i)
if (pj_param (P->ctx, P->params, "ts").i) {
Q->scale_0 = pj_param (P->ctx, P->params, "ds").f;

if (pj_param (P->ctx, P->params, "ttheta").i && Q->scale_0 == 0.0)
return freeup_msg(P, -PJD_ERR_INVALID_SCALE);
}

/* Translation rates */
if (pj_param(P->ctx, P->params, "tdx").i)
Expand Down
1 change: 1 addition & 0 deletions src/pj_strerrno.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pj_err_list[] = {
"invalid sweep axis, choose x or y", /* -49 */
"malformed pipeline", /* -50 */
"unit conversion factor must be > 0", /* -51 */
"invalid scale", /* -52 */
};

char *pj_strerrno(int err) {
Expand Down
1 change: 1 addition & 0 deletions src/projects.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ struct FACTORS {
#define PJD_ERR_AXIS -47
#define PJD_ERR_GRID_AREA -48
#define PJD_ERR_CATALOG -49
#define PJD_ERR_INVALID_SCALE -52

struct projFileAPI_t;

Expand Down

0 comments on commit 37369f2

Please sign in to comment.