rrd: fix integer underflow
Causes a panic if last_update is smaller than RRD_DATA_ENTRIES*reso, which (I believe) can happen when inserting the first value for a DB. Clamp the value to 0 in that case. Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
parent
dec00364b3
commit
da6e67b321
|
@ -60,7 +60,7 @@ impl RRA {
|
|||
|
||||
let min_time = epoch - (RRD_DATA_ENTRIES as u64)*reso;
|
||||
let min_time = (min_time/reso + 1)*reso;
|
||||
let mut t = last_update - (RRD_DATA_ENTRIES as u64)*reso;
|
||||
let mut t = last_update.saturating_sub((RRD_DATA_ENTRIES as u64)*reso);
|
||||
let mut index = ((t/reso) % (RRD_DATA_ENTRIES as u64)) as usize;
|
||||
for _ in 0..RRD_DATA_ENTRIES {
|
||||
t += reso; index = (index + 1) % RRD_DATA_ENTRIES;
|
||||
|
|
Loading…
Reference in New Issue