diff --git a/ChangeLog.d/fix-gettimeofday-overflow.txt b/ChangeLog.d/fix-gettimeofday-overflow.txt new file mode 100644 index 0000000000..99a049d8c8 --- /dev/null +++ b/ChangeLog.d/fix-gettimeofday-overflow.txt @@ -0,0 +1,4 @@ +Bugfix + * Fix possible integer overflow in mbedtls_timing_hardclock(), which + could cause a crash for certain platforms & compiler options. + diff --git a/library/timing.c b/library/timing.c index 6c14a4fd01..ca29e56a66 100644 --- a/library/timing.c +++ b/library/timing.c @@ -223,7 +223,7 @@ 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 */