Merge pull request #6826 from daverodgman/fix_gettimeofday

Fix gettimeofday overflow
This commit is contained in:
Dave Rodgman 2022-12-20 16:01:53 +00:00 committed by GitHub
commit 2038da9266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -0,0 +1,3 @@
Bugfix
* Fix possible integer overflow in mbedtls_timing_hardclock(), which
could cause a crash in programs/test/benchmark.

View File

@ -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 */