Merge pull request #741 from jevinskie/jev/bug/sscanf-overflows

Fix sscanf overflows
This commit is contained in:
Stephen Williams 2022-07-08 09:59:22 -07:00 committed by GitHub
commit e3a9591960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -188,7 +188,7 @@ static int read_vector(const char *string, s_vpi_value *val, vpiHandle var)
*/ */
static int read_time(const char *string, s_vpi_value *val, PLI_INT32 scope_unit) { static int read_time(const char *string, s_vpi_value *val, PLI_INT32 scope_unit) {
PLI_UINT64 period; PLI_UINT64 period;
char units[2]; char units[3];
int time_unit, processed_chars; int time_unit, processed_chars;
if(sscanf(string, "%" PLI_UINT64_FMT " %2s%n", &period, units, &processed_chars) != 2) if(sscanf(string, "%" PLI_UINT64_FMT " %2s%n", &period, units, &processed_chars) != 2)
@ -720,7 +720,7 @@ static PLI_INT32 ivlh_read_calltf(ICARUS_VPI_CONST PLI_BYTE8*name)
case FORMAT_BOOL: case FORMAT_BOOL:
{ {
char buf[5]; char buf[6];
val.format = vpiIntVal; val.format = vpiIntVal;
if(sscanf(string, "%5s%n", buf, &processed_chars) == 1) if(sscanf(string, "%5s%n", buf, &processed_chars) == 1)