Skip to content

Floating point to long conversion in BackoffSupervisor::CalculateDelay could overflow #3318

@ianclegg

Description

@ianclegg

While porting replyWhileStopped in #3317 for I noticed a risky double to long conversion using an explicit cast. With a large value the long will overflow and we'll have a negative timespan.

var max = Math.Min(maxBackoff.Ticks, minBackoff.Ticks * Math.Pow(2, restartCount)) * rand;
if (max >= double.MaxValue)
{
   return maxBackoff;
}
else
{
    return new TimeSpan((long)max);
}

Ending up with a timespan large enough to overflow is probably a user error in itself, but it shouldn't be exacerbated by Akka.

It's a minor fix, happy to raise a PR for it if your interested

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions