-
Notifications
You must be signed in to change notification settings - Fork 21
Description
If you have an existing log file, and then write to a FileRotate instance on it, that can cause a panic due to attempted integer wraparound.
This is specifically when the existing log file is larger than the ContentLimit::Bytes setting.
At that case, specifically in lib.rs of file_rotate create, over in fn write, this calculation in debug mode:
let bytes_left = bytes - self.count;
Can attempt to calculate a negative value, and then in debug mode, the error there is because of an attempted wraparound.
I initially picked up this error in release mode, when the panic I was receiving was because of an attempt to perform out of bounds array access, based on the wrapped-around contents of bytes_left.
Basically, it looks like there are cases where "self.count" can be larger than "bytes".