From fe9ca3a4ce6544e803db900e0744e9eefd3b7c46 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 1 May 2024 13:45:00 -0400 Subject: [PATCH] Corrected the routine that parses MASKHINTS_* in cell properties to avoid an infinite loop in the case that the mask hint does not have a number of values that is a multiple of 4. --- VERSION | 2 +- cif/CIFhier.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 1f0285c5..58ac8b5c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.475 +8.3.476 diff --git a/cif/CIFhier.c b/cif/CIFhier.c index 09fd8f05..a24dead8 100644 --- a/cif/CIFhier.c +++ b/cif/CIFhier.c @@ -285,7 +285,7 @@ cifFlatMaskHints(name, value, mhd) Rect r, newr; char *vptr, *newval, *lastval, *propvalue; bool propfound; - int lastlen; + int lastlen, numvals; if (!strncmp(name, "MASKHINTS_", 10)) { @@ -293,8 +293,9 @@ cifFlatMaskHints(name, value, mhd) vptr = value; while (*vptr != '\0') { - if (sscanf(vptr, "%d %d %d %d", &r.r_xbot, &r.r_ybot, - &r.r_xtop, &r.r_ytop) == 4) + numvals = sscanf(vptr, "%d %d %d %d", &r.r_xbot, &r.r_ybot, + &r.r_xtop, &r.r_ytop); + if (numvals == 4) { /* Transform rectangle to top level coordinates */ GeoTransRect(mhd->mh_trans, &r, &newr); @@ -320,6 +321,12 @@ cifFlatMaskHints(name, value, mhd) while (*vptr && !isspace(*vptr)) vptr++; while (*vptr && isspace(*vptr)) vptr++; } + else + { + TxError("MASKHINTS_%s: Expected 4 values, found only %d\n", + name + 10, numvals); + break; + } } /* Check if name exists already in the flattened cell */