Skip to content

Commit fe9ca3a

Browse files
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.
1 parent 0ae54b5 commit fe9ca3a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.3.475
1+
8.3.476

cif/CIFhier.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,17 @@ cifFlatMaskHints(name, value, mhd)
285285
Rect r, newr;
286286
char *vptr, *newval, *lastval, *propvalue;
287287
bool propfound;
288-
int lastlen;
288+
int lastlen, numvals;
289289

290290
if (!strncmp(name, "MASKHINTS_", 10))
291291
{
292292
newval = (char *)NULL;
293293
vptr = value;
294294
while (*vptr != '\0')
295295
{
296-
if (sscanf(vptr, "%d %d %d %d", &r.r_xbot, &r.r_ybot,
297-
&r.r_xtop, &r.r_ytop) == 4)
296+
numvals = sscanf(vptr, "%d %d %d %d", &r.r_xbot, &r.r_ybot,
297+
&r.r_xtop, &r.r_ytop);
298+
if (numvals == 4)
298299
{
299300
/* Transform rectangle to top level coordinates */
300301
GeoTransRect(mhd->mh_trans, &r, &newr);
@@ -320,6 +321,12 @@ cifFlatMaskHints(name, value, mhd)
320321
while (*vptr && !isspace(*vptr)) vptr++;
321322
while (*vptr && isspace(*vptr)) vptr++;
322323
}
324+
else
325+
{
326+
TxError("MASKHINTS_%s: Expected 4 values, found only %d\n",
327+
name + 10, numvals);
328+
break;
329+
}
323330
}
324331

325332
/* Check if name exists already in the flattened cell */

0 commit comments

Comments
 (0)