From bcf58defe0e83be6fdf5a0e2a554648a6332e739 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 8 Dec 2022 07:30:23 -0500 Subject: [PATCH] Update include/gtkwave from upstream --- include/gtkwave/fstapi.c | 68 +++++++++++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/include/gtkwave/fstapi.c b/include/gtkwave/fstapi.c index 5e9529d44..11cb0c501 100644 --- a/include/gtkwave/fstapi.c +++ b/include/gtkwave/fstapi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2018 Tony Bybell. + * Copyright (c) 2009-2023 Tony Bybell. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -4130,26 +4130,35 @@ if(xc->do_rewind) if(!(isfeof=feof(xc->fh))) { int tag = fgetc(xc->fh); + int cl; switch(tag) { case FST_ST_VCD_SCOPE: xc->hier.htyp = FST_HT_SCOPE; xc->hier.u.scope.typ = fgetc(xc->fh); xc->hier.u.scope.name = pnt = xc->str_scope_nam; + cl = 0; while((ch = fgetc(xc->fh))) { - *(pnt++) = ch; + if(cl <= FST_ID_NAM_SIZ) + { + pnt[cl++] = ch; + } }; /* scopename */ - *pnt = 0; - xc->hier.u.scope.name_length = pnt - xc->hier.u.scope.name; + pnt[cl] = 0; + xc->hier.u.scope.name_length = cl; xc->hier.u.scope.component = pnt = xc->str_scope_comp; + cl = 0; while((ch = fgetc(xc->fh))) { - *(pnt++) = ch; + if(cl <= FST_ID_NAM_SIZ) + { + pnt[cl++] = ch; + } }; /* scopecomp */ - *pnt = 0; - xc->hier.u.scope.component_length = pnt - xc->hier.u.scope.component; + pnt[cl] = 0; + xc->hier.u.scope.component_length = cl; break; case FST_ST_VCD_UPSCOPE: @@ -4161,12 +4170,16 @@ if(!(isfeof=feof(xc->fh))) xc->hier.u.attr.typ = fgetc(xc->fh); xc->hier.u.attr.subtype = fgetc(xc->fh); xc->hier.u.attr.name = pnt = xc->str_scope_nam; + cl = 0; while((ch = fgetc(xc->fh))) { - *(pnt++) = ch; + if(cl <= FST_ID_NAM_SIZ) + { + pnt[cl++] = ch; + } }; /* scopename */ - *pnt = 0; - xc->hier.u.attr.name_length = pnt - xc->hier.u.scope.name; + pnt[cl] = 0; + xc->hier.u.attr.name_length = cl; xc->hier.u.attr.arg = fstReaderVarint64(xc->fh); @@ -4221,12 +4234,16 @@ if(!(isfeof=feof(xc->fh))) xc->hier.u.var.typ = tag; xc->hier.u.var.direction = fgetc(xc->fh); xc->hier.u.var.name = pnt = xc->str_scope_nam; + cl = 0; while((ch = fgetc(xc->fh))) { - *(pnt++) = ch; + if(cl <= FST_ID_NAM_SIZ) + { + pnt[cl++] = ch; + } }; /* varname */ - *pnt = 0; - xc->hier.u.var.name_length = pnt - xc->hier.u.var.name; + pnt[cl] = 0; + xc->hier.u.var.name_length = cl; xc->hier.u.var.length = fstReaderVarint32(xc->fh); if(tag == FST_VT_VCD_PORT) { @@ -4273,6 +4290,7 @@ unsigned int num_signal_dyn = 65536; int attrtype, subtype; uint64_t attrarg; fstHandle maxhandle_scanbuild; +int cl; if(!xc) return(0); @@ -4355,11 +4373,15 @@ while(!feof(xc->fh)) scopetype = fgetc(xc->fh); if((scopetype < FST_ST_MIN) || (scopetype > FST_ST_MAX)) scopetype = FST_ST_VCD_MODULE; pnt = str; + cl = 0; while((ch = fgetc(xc->fh))) { - *(pnt++) = ch; + if(cl <= FST_ID_NAM_ATTR_SIZ) + { + pnt[cl++] = ch; + } }; /* scopename */ - *pnt = 0; + pnt[cl] = 0; while(fgetc(xc->fh)) { }; /* scopecomp */ if(fv) fprintf(fv, "$scope %s %s $end\n", modtypes[scopetype], str); @@ -4373,11 +4395,15 @@ while(!feof(xc->fh)) attrtype = fgetc(xc->fh); subtype = fgetc(xc->fh); pnt = str; + cl = 0; while((ch = fgetc(xc->fh))) { - *(pnt++) = ch; + if(cl <= FST_ID_NAM_ATTR_SIZ) + { + pnt[cl++] = ch; + } }; /* attrname */ - *pnt = 0; + pnt[cl] = 0; if(!str[0]) { strcpy(str, "\"\""); } @@ -4458,11 +4484,15 @@ while(!feof(xc->fh)) vartype = tag; /* vardir = */ fgetc(xc->fh); /* unused in VCD reader, but need to advance read pointer */ pnt = str; + cl = 0; while((ch = fgetc(xc->fh))) { - *(pnt++) = ch; + if(cl <= FST_ID_NAM_ATTR_SIZ) + { + pnt[cl++] = ch; + } }; /* varname */ - *pnt = 0; + pnt[cl] = 0; len = fstReaderVarint32(xc->fh); alias = fstReaderVarint32(xc->fh);