diff --git a/ChangeLog.d/fix-gettimeofday-overflow.txt b/ChangeLog.d/fix-gettimeofday-overflow.txt new file mode 100644 index 0000000000..b7e10d2b0a --- /dev/null +++ b/ChangeLog.d/fix-gettimeofday-overflow.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix possible integer overflow in mbedtls_timing_hardclock(), which + could cause a crash in programs/test/benchmark. diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c index 6313c522a6..1ad2034d4a 100644 --- a/programs/test/benchmark.c +++ b/programs/test/benchmark.c @@ -398,7 +398,7 @@ static unsigned long mbedtls_timing_hardclock( void ) } gettimeofday( &tv_cur, NULL ); - return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000 + return( ( tv_cur.tv_sec - tv_init.tv_sec ) * 1000000U + ( tv_cur.tv_usec - tv_init.tv_usec ) ); } #endif /* !HAVE_HARDCLOCK */