bssgp: Calculate the avg_delay_ms in 32bit only (Coverity)

Currently the delay_sum is stored in 64 to avoid overflow errors.
But only the result of tv_sec * 1000 is casted to 64 bit, resulting
in an overflow if the accumulated queue delay reached 25 days (which
will not happen in practice, unless there are >200k LLC messages with
a max of 10s delay each in the queue). If that were the case, the
only impact would be a wrong number in a log message and in the BSSGP
FLOW CONTROL message.

This commit changes the calculations so that they are done in 32 bit
only, rather than to do the calculation in 64 bit properly.

Fixes: Coverity CID 1298705
Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2015-06-11 12:03:18 +02:00
parent d0aee85b29
commit 0ae4313800
1 changed files with 1 additions and 1 deletions

View File

@ -572,7 +572,7 @@ static uint32_t compute_bucket_size(struct gprs_rlcmac_bts *bts,
static uint32_t get_and_reset_avg_queue_delay(void)
{
struct timeval *delay_sum = &the_pcu.queue_delay_sum;
uint64_t delay_sum_ms = delay_sum->tv_sec * 1000 +
uint32_t delay_sum_ms = delay_sum->tv_sec * 1000 +
delay_sum->tv_usec / 1000000;
uint32_t avg_delay_ms = 0;