atifaziz / NCrontab

Crontab for .NET

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CrontabSchedule.Parse throws OverflowException instead of CrontabException

Metalnem opened this issue · comments

CrontabSchedule.Parse can sometimes throw OverflowException instead of CrontabException. Here is the full program to reproduce this:

namespace NCrontab.Run
{
  public class Program
  {
    public static void Main(string[] args)
    {
      CrontabSchedule.Parse("2222222222222222222222222220  12 * */2 Mon");
    }
  }
}

And here is the full stack trace:

An unhandled exception of type 'System.OverflowException' occurred in System.Private.CoreLib.dll: 'Value was either too large or too small for an Int32.'
   at System.Number.ParseInt32(ReadOnlySpan`1 s, NumberStyles style, NumberFormatInfo info)
   at NCrontab.CrontabFieldImpl.ParseValue(String str)
   at NCrontab.CrontabFieldImpl.InternalParse[T](String str, CrontabFieldAccumulator`1 acc, T success, Func`2 errorSelector)
   at NCrontab.CrontabFieldImpl.TryParse[T](String str, CrontabFieldAccumulator`1 acc, T success, Func`2 errorSelector)
   at NCrontab.CrontabField.TryParse[T](CrontabFieldKind kind, String expression, Func`2 valueSelector, Func`2 errorSelector)
   at NCrontab.CrontabSchedule.TryParse[T](String expression, ParseOptions options, Func`2 valueSelector, Func`2 errorSelector)

Found via SharpFuzz.