From 777f7ef09579b3f1ad84241701c6b1d0d5332876 Mon Sep 17 00:00:00 2001 From: "R. Timothy Edwards" Date: Thu, 15 Jan 2026 16:39:18 -0500 Subject: [PATCH] Found a counting issue with netcmp output that will overrun the output string buffer if the size of the copied string is just the wrong amount, due to the use of strcpy() instead of strncpy() in at least one place. Just hacked a solution by allocating more space for the string, but this should be fixed properly. Also: Discovered that the "zero valued resistor" routine looks for shorted ports in the wrong place, and if it finds shorted ports it wrongly decides that the device it's looking at is a zero-valued resistor whether or not it really is zero-valued. --- VERSION | 2 +- base/flatten.c | 7 ++++--- base/netcmp.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/VERSION b/VERSION index cbdae04..6a7b4fe 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.5.314 +1.5.315 diff --git a/base/flatten.c b/base/flatten.c index 4265e8a..1daaf80 100644 --- a/base/flatten.c +++ b/base/flatten.c @@ -2018,7 +2018,10 @@ PrematchLists(char *name1, int file1, char *name2, int file2) break; } } + if (found) break; + } + if (found) { /* Beware remove shorting devices that */ /* connect two ports. Otherwise the */ /* port lists get screwed up. It is */ @@ -2049,14 +2052,12 @@ PrematchLists(char *name1, int file1, char *name2, int file2) "matching may be affected.\n", ob2->name); // found = FALSE; - found = TRUE; break; } } } - - if (found) break; } + if (found) { Fprintf(stdout, "Removing zero-valued device " "%s from cell %s (%d) makes a better " diff --git a/base/netcmp.c b/base/netcmp.c index 587b7b1..529b1b9 100644 --- a/base/netcmp.c +++ b/base/netcmp.c @@ -1622,8 +1622,8 @@ void FormatIllegalElementClasses() char *permcount; int bytesleft; - permname = CALLOC(right_col_end + 2, sizeof(char)); - permcount = CALLOC(right_col_end + 2, sizeof(char)); + permname = CALLOC(right_col_end + 100, sizeof(char)); + permcount = CALLOC(right_col_end + 100, sizeof(char)); ostr = output_string_init(); found = 0;