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.
This commit is contained in:
Tim Edwards 2024-05-01 13:45:00 -04:00
parent 0ae54b500a
commit fe9ca3a4ce
2 changed files with 11 additions and 4 deletions

View File

@ -1 +1 @@
8.3.475 8.3.476

View File

@ -285,7 +285,7 @@ cifFlatMaskHints(name, value, mhd)
Rect r, newr; Rect r, newr;
char *vptr, *newval, *lastval, *propvalue; char *vptr, *newval, *lastval, *propvalue;
bool propfound; bool propfound;
int lastlen; int lastlen, numvals;
if (!strncmp(name, "MASKHINTS_", 10)) if (!strncmp(name, "MASKHINTS_", 10))
{ {
@ -293,8 +293,9 @@ cifFlatMaskHints(name, value, mhd)
vptr = value; vptr = value;
while (*vptr != '\0') while (*vptr != '\0')
{ {
if (sscanf(vptr, "%d %d %d %d", &r.r_xbot, &r.r_ybot, numvals = sscanf(vptr, "%d %d %d %d", &r.r_xbot, &r.r_ybot,
&r.r_xtop, &r.r_ytop) == 4) &r.r_xtop, &r.r_ytop);
if (numvals == 4)
{ {
/* Transform rectangle to top level coordinates */ /* Transform rectangle to top level coordinates */
GeoTransRect(mhd->mh_trans, &r, &newr); GeoTransRect(mhd->mh_trans, &r, &newr);
@ -320,6 +321,12 @@ cifFlatMaskHints(name, value, mhd)
while (*vptr && !isspace(*vptr)) vptr++; while (*vptr && !isspace(*vptr)) vptr++;
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 */ /* Check if name exists already in the flattened cell */