From 82c79b36eef29489d10c5c15b51c99d817894f5a Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Mon, 19 Sep 2022 17:26:42 -0400 Subject: [PATCH] Added a check for unfortunate values of a MAG record in a GDS text record. Failure to use the right 8-byte real format can produce bizarre results where a label's bounding box ends up in some random place and messes up an entire top level circuit's bounding box. --- VERSION | 2 +- calma/CalmaRdpt.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 0fe264b4..f0293101 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.324 +8.3.325 diff --git a/calma/CalmaRdpt.c b/calma/CalmaRdpt.c index 398d478d..951df9cd 100644 --- a/calma/CalmaRdpt.c +++ b/calma/CalmaRdpt.c @@ -809,10 +809,16 @@ calmaElementText() if (nbytes > 0 && rtype == CALMA_MAG) { calmaReadR8(&dval); - - /* Assume that MAG is the label size in microns */ - /* "size" is the label size in 10 * (database units) */ - size = (int)((dval * 1000 * cifCurReadStyle->crs_multiplier) + /* Sanity check on dval (must be nonzero positive) */ + if ((dval <= 0) || (dval > 10000)) + { + CalmaReadError("Invalid text magnification %lg.\n", dval); + /* Keep default size */ + } + else + /* Assume that MAG is the label size in microns */ + /* "size" is the label size in 10 * (database units) */ + size = (int)((dval * 1000 * cifCurReadStyle->crs_multiplier) / cifCurReadStyle->crs_scaleFactor); } else