aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2022-10-02 09:04:06 +0200
committerToni Uhlig <matzeton@googlemail.com>2022-10-02 09:04:06 +0200
commitac34884e9f494aeb9166e81238293e54c730a415 (patch)
treefc60526298b67fe3625cb161d92cbf2eca63b53d
parent503aac70bccfecfc920e30b5d7d32e252f0cae92 (diff)
Fix ndpi_timeval_to_milliseconds/microseconds for platforms with tv_usec is an unsigned int.fix/ndpi-pkt-timeval
* implicit conversion to an 32 bit unsigned int leads to an overflow Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r--src/lib/ndpi_classify.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/ndpi_classify.c b/src/lib/ndpi_classify.c
index e94bf2872..5c4fb2119 100644
--- a/src/lib/ndpi_classify.c
+++ b/src/lib/ndpi_classify.c
@@ -662,8 +662,9 @@ ndpi_timer_clear(pkt_timeval *a)
u_int64_t
ndpi_timeval_to_milliseconds(pkt_timeval ts)
{
- u_int64_t result = ts.tv_usec / 1000 + ts.tv_sec * 1000;
- return result;
+ u_int64_t sec = ts.tv_sec;
+ u_int64_t usec = ts.tv_usec;
+ return usec / 1000 + sec * 1000;
}
/**
@@ -674,8 +675,9 @@ ndpi_timeval_to_milliseconds(pkt_timeval ts)
u_int64_t
ndpi_timeval_to_microseconds(pkt_timeval ts)
{
- u_int64_t result = ts.tv_usec + ts.tv_sec * 1000 * 1000;
- return result;
+ u_int64_t sec = ts.tv_sec;
+ u_int64_t usec = ts.tv_usec;
+ return usec + sec * 1000 * 1000;;
}
void