rtemsbsd: Catch timeout overflows

Update #4475
This commit is contained in:
Chris Johns 2021-07-19 18:57:51 +10:00
parent 684cf3cdc2
commit 2a01430ba5

View File

@ -37,6 +37,7 @@
#include <sys/time.h>
#include <limits.h>
#include <rtems/score/timespec.h>
/*
@ -45,10 +46,15 @@
int
tvtohz(struct timeval *tv)
{
struct timespec ts;
struct timespec ts;
uint32_t ticks;
ts.tv_sec = tv->tv_sec;
ts.tv_nsec = tv->tv_usec * 1000;
ts.tv_sec = tv->tv_sec;
ts.tv_nsec = tv->tv_usec * 1000;
return (int) _Timespec_To_ticks( &ts );
ticks = _Timespec_To_ticks(&ts);
if (ticks > INT_MAX)
ticks = INT_MAX;
return ticks;
}