Skip to content

CrontabSchedule.Parse throws OverflowException instead of CrontabException #43

Open

Description

@Metalnem

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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