aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2022-10-02 12:48:24 +0200
committerGitHub <noreply@github.com>2022-10-02 12:48:24 +0200
commit66a8010ef7337aa734e430c40c690f4470384f62 (patch)
treebe46fb6bb04afaa3b147430bd60da060d149e60f
parentc83e0b3c8d780df6fb5b064ff7c1c03e758a03a1 (diff)
Fix ndpi_timeval_to_milliseconds/microseconds for platforms with tv_usec is an unsigned int. (#1762)
* implicit conversion to an 32 bit unsigned int leads to an overflow Signed-off-by: Toni Uhlig <matzeton@googlemail.com> 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