diff --git a/vpi/cppcheck.sup b/vpi/cppcheck.sup index 4c260cd00..0ec47e24c 100644 --- a/vpi/cppcheck.sup +++ b/vpi/cppcheck.sup @@ -3,6 +3,7 @@ // problems will not be fixed. // fstapi.c from GTKWave +obsoleteFunctionsasctime:fstapi.c:652 variableScope:fstapi.c:1707 variableScope:fstapi.c:1965 variableScope:fstapi.c:2109 @@ -11,7 +12,7 @@ variableScope:fstapi.c:2269 variableScope:fstapi.c:2976 variableScope:fstapi.c:3304 variableScope:fstapi.c:3313 -variableScope:fstapi.c:4980 +variableScope:fstapi.c:4982 // lxt2_write.c from GTKWave obsoleteFunctionsalloca:lxt2_write.c:1813 diff --git a/vpi/fstapi.c b/vpi/fstapi.c index bac88f44c..f4f6611b3 100644 --- a/vpi/fstapi.c +++ b/vpi/fstapi.c @@ -3820,7 +3820,7 @@ for(;;) uint64_t tpval; int ti; - fseeko(xc->f, blkpos + seclen - 24, SEEK_SET); + if(fseeko(xc->f, blkpos + seclen - 24, SEEK_SET) != 0) break; tsec_uclen = fstReaderUint64(xc->f); tsec_clen = fstReaderUint64(xc->f); tsec_nitems = fstReaderUint64(xc->f); @@ -3828,7 +3828,9 @@ for(;;) printf("\ttime section unc: %d, com: %d (%d items)\n", (int)tsec_uclen, (int)tsec_clen, (int)tsec_nitems); #endif + if(tsec_clen > seclen) break; /* corrupted tsec_clen: by definition it can't be larger than size of section */ ucdata = malloc(tsec_uclen); + if(!ucdata) break; /* malloc fail as tsec_uclen out of range from corrupted file */ destlen = tsec_uclen; sourcelen = tsec_clen;