aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-06-11 12:03:18 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-06-11 13:13:55 +0200
commit0ae431380015a5c6a944a9edd1620e56b0b65445 (patch)
tree2911f3990985ba87be3aecca374d578c5cedac19 /src
parentd0aee85b29a17e6ef3fb1454a798e10ced0d0266 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/gprs_bssgp_pcu.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index 9bdae39d..802ca9a4 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -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;