Prevents infinite propagation on input proxy and judge.

This commit is contained in:
2023-02-28 13:47:38 +08:00
parent a755cc13bd
commit 1a30149942
2 changed files with 26 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ using Cryville.Common.Pdt;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Runtime.Serialization;
using System.Text.Formatting;
namespace Cryville.Crtr {
@@ -134,7 +135,7 @@ namespace Cryville.Crtr {
if (actlist.Count > 0) {
_numbuf3 = ft; _numsrc3.Invalidate(); _etor.ContextCascadeUpdate(_var_ft, _numsrc3);
_numbuf4 = tt; _numsrc4.Invalidate(); _etor.ContextCascadeUpdate(_var_tt, _numsrc4);
var index = 0;
int index = 0, iter = 0;
while (index >= 0 && index < actlist.Count) {
var ev = actlist[index];
_numbuf1 = (float)ev.StartTime; _numsrc1.Invalidate(); _etor.ContextCascadeUpdate(_var_fn, _numsrc1);
@@ -154,19 +155,21 @@ namespace Cryville.Crtr {
if (index < 0) index = ~index;
}
else index++;
if (iter++ >= 16) throw new JudgePropagationException();
}
else index++;
}
}
}
bool Pass(JudgeEvent ev, float time, Identifier[] ids) {
bool Pass(JudgeEvent ev, float time, Identifier[] ids, int depth = 0) {
if (depth >= 16) throw new JudgePropagationException();
foreach (var i in ids) {
var def = _rs.judges[i];
if (def.hit != null) _etor.Evaluate(_flagop, def.hit);
else _flag = true;
if (_flag) {
if (def.scores != null) UpdateScore(def.scores);
if (def.pass != null) Pass(ev, time, def.pass);
if (def.pass != null) Pass(ev, time, def.pass, depth + 1);
ev.Handler.ReportJudge(ev, time, i);
return true;
}
@@ -323,4 +326,12 @@ namespace Cryville.Crtr {
public string format = "";
}
#endregion
[Serializable]
public class JudgePropagationException : Exception {
public JudgePropagationException() : base("Judge propagation limit reached\nThe ruleset has invalid judge definitions") { }
public JudgePropagationException(string message) : base(message) { }
public JudgePropagationException(string message, Exception inner) : base(message, inner) { }
protected JudgePropagationException(SerializationInfo info, StreamingContext context) : base(info, context) { }
}
}