Skip to content

Existing log file can cause panic #20

@wizzardx

Description

@wizzardx

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".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions