Skip to content

Commit

Permalink
Min-valued nano durations would throw Overflow exceptions, should ins…
Browse files Browse the repository at this point in the history
…tead resolve to 'Forever' value
  • Loading branch information
definitelynotagoblin committed Sep 13, 2024
1 parent 8cd3b60 commit f280442
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/CommonLib/Processors/LdapPropertyProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,11 @@ private static List<string> ConvertEncryptionTypes(string encryptionTypes)

private static string ConvertNanoDuration(long duration)
{
// In case duration is long.MinValue, Math.Abs will overflow. Value represents Forever or Never
if (duration == long.MinValue) {
return "Forever";
}

// duration is in 100-nanosecond intervals
// Convert it to TimeSpan (which uses 1 tick = 100 nanoseconds)
TimeSpan durationSpan = TimeSpan.FromTicks(Math.Abs(duration));
Expand Down

0 comments on commit f280442

Please sign in to comment.