diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2022-09-04 17:19:12 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2022-09-04 18:15:41 +0200 |
commit | 1b43a4753c3ed128f66ce5c114346f114cb2cc79 (patch) | |
tree | db41781796be3871f7e9685a6232fad9af168923 | |
parent | a329730d24bc99a77a8e49334ac146fdaf50fb65 (diff) |
Fix broken ndpi_timeval_to_(milli|micro)seconds (>UINT_MAX).fix/broken-ndpi_timeval_to_microseconds
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | src/include/ndpi_classify.h | 4 | ||||
-rw-r--r-- | src/lib/ndpi_classify.c | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/include/ndpi_classify.h b/src/include/ndpi_classify.h index ab9212832..3baeb1e13 100644 --- a/src/include/ndpi_classify.h +++ b/src/include/ndpi_classify.h @@ -85,8 +85,8 @@ unsigned int ndpi_timer_eq(const pkt_timeval *a, const pkt_timeval *b); unsigned int ndpi_timer_lt(const pkt_timeval *a, const pkt_timeval *b); void ndpi_timer_sub(const pkt_timeval *a, const pkt_timeval *b, pkt_timeval *result); void ndpi_timer_clear(pkt_timeval *a); -unsigned int ndpi_timeval_to_milliseconds(pkt_timeval ts); -unsigned int ndpi_timeval_to_microseconds(pkt_timeval ts); +u_int64_t ndpi_timeval_to_milliseconds(pkt_timeval ts); +u_int64_t ndpi_timeval_to_microseconds(pkt_timeval ts); void ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len); #endif /* NDPI_CLASSIFY_H */ diff --git a/src/lib/ndpi_classify.c b/src/lib/ndpi_classify.c index 61756cc16..e94bf2872 100644 --- a/src/lib/ndpi_classify.c +++ b/src/lib/ndpi_classify.c @@ -657,24 +657,24 @@ ndpi_timer_clear(pkt_timeval *a) /** * \brief Calculate the milliseconds representation of a timeval. * \param ts Timeval - * \return unsigned int - Milliseconds + * \return unsigned int (64bit) - Milliseconds */ -unsigned int +u_int64_t ndpi_timeval_to_milliseconds(pkt_timeval ts) { - unsigned int result = ts.tv_usec / 1000 + ts.tv_sec * 1000; + u_int64_t result = ts.tv_usec / 1000 + ts.tv_sec * 1000; return result; } /** * \brief Calculate the microseconds representation of a timeval. * \param ts Timeval - * \return unsigned int - Milliseconds + * \return unsigned int (64bit) - Microseconds */ -unsigned int +u_int64_t ndpi_timeval_to_microseconds(pkt_timeval ts) { - unsigned int result = ts.tv_usec + ts.tv_sec * 1000 * 1000; + u_int64_t result = ts.tv_usec + ts.tv_sec * 1000 * 1000; return result; } |