diff --git a/apps/iris/src/common/constants/constants.go b/apps/iris/src/common/constants/constants.go index 0aae1ce8cc..dccb337ead 100644 --- a/apps/iris/src/common/constants/constants.go +++ b/apps/iris/src/common/constants/constants.go @@ -53,3 +53,5 @@ const ( EXCHANGE = "judger-exchange" RESULT_KEY = "result" ) + +const MAX_OUTPUT = 1048576 // 1MB diff --git a/apps/iris/src/handler/judge-handler.go b/apps/iris/src/handler/judge-handler.go index 547ca24afc..14241b1435 100644 --- a/apps/iris/src/handler/judge-handler.go +++ b/apps/iris/src/handler/judge-handler.go @@ -347,6 +347,10 @@ func (j *JudgeHandler) judgeTestcase(idx int, dir string, validReq *Request, res.SetJudgeExecResult(runResult.ExecResult) res.Output = string(runResult.Output) + if len(res.Output) > constants.MAX_OUTPUT { + res.Output = res.Output[:constants.MAX_OUTPUT] + } + if runResult.ExecResult.ResultCode != sandbox.RUN_SUCCESS { res.SetJudgeResultCode(SandboxResultCodeToJudgeResultCode(runResult.ExecResult.ResultCode)) goto Send