Commit 27086011 authored by Joanne Hugé's avatar Joanne Hugé

Properly cast dist_to_interval to avoid overflow

parent 622d9e4d
......@@ -146,10 +146,10 @@ static void *packet_receiving_thread(void *p) {
stats->max_interval = diff > stats->max_interval ? diff : stats->max_interval;
if(enable_histograms) {
dist_to_interval = (diff - param->interval) / 1000;
dist_to_interval = (((int64_t)diff) - param->interval) / 1000;
dist_to_interval += MAX_HIST_VAL / 2;
if( dist_to_interval > ((int)MAX_HIST_VAL) || dist_to_interval < 0 ) {
fprintf(stderr, "jitter higher than MAX_HIST_VAL\n");
fprintf(stderr, "jitter higher than MAX_HIST_VAL: %" PRIi64 "\n", dist_to_interval);
exit(EXIT_FAILURE);
}
else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment