From 59808690406067c6c057646bc6c144da9942becf Mon Sep 17 00:00:00 2001 From: Giles Atkinson <“gatk555@gmail.com”> Date: Wed, 20 Nov 2024 21:42:23 +0000 Subject: [PATCH] Apply Patch #119 - "Fix buffer overflow in src/xspice/icm/digital/d_state/cfunc.mod". The change is not identical to the supplied patch. It was slightly modified to make the original code more sane. Found and patched by Artem Sinkevich. --- src/xspice/icm/digital/d_state/cfunc.mod | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xspice/icm/digital/d_state/cfunc.mod b/src/xspice/icm/digital/d_state/cfunc.mod index da8413223..96246f489 100644 --- a/src/xspice/icm/digital/d_state/cfunc.mod +++ b/src/xspice/icm/digital/d_state/cfunc.mod @@ -1365,14 +1365,15 @@ static int cm_read_state_file(FILE *state_file, State_Table_t *table) } i = 0; - s = temp; - while ( fgets(s,MAX_STRING_SIZE,state_file) != NULL) { + while (fgets(temp, MAX_STRING_SIZE, state_file) != NULL) { /* Test this string to see if it is whitespace... */ + s = temp; base_address = s; while(isspace_c(*s) || (*s == '*')) (s)++; - if ( *s != '\0' ) { /* This is not a blank line, so process... */ + if ( *s != '\0' ) { + /* This is not a blank line, so process... */ s = base_address; if ( '*' != s[0] ) { @@ -1571,7 +1572,6 @@ static int cm_read_state_file(FILE *state_file, State_Table_t *table) } i++; } - s = temp; } } return 0;