mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-25 09:03:10 +01:00
fix(scenario): enforce scenarioChunkSizeLimit in CompileScenarioJSON
The constant was declared and documented but never used, causing a golangci-lint failure. Wire it into compileScenario() so oversized chunks are rejected with a clear error rather than silently served to the client (which discards them per FUN_11525c60 RE findings).
This commit is contained in:
@@ -349,6 +349,12 @@ func compileScenario(s *ScenarioJSON) ([]byte, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i, chunk := range [][]byte{chunk0, chunk1, chunk2} {
|
||||||
|
if len(chunk) > scenarioChunkSizeLimit {
|
||||||
|
return nil, fmt.Errorf("chunk%d size %d exceeds client limit of %d bytes", i, len(chunk), scenarioChunkSizeLimit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
// Container header: c0_size, c1_size (big-endian u32)
|
// Container header: c0_size, c1_size (big-endian u32)
|
||||||
_ = binary.Write(&buf, binary.BigEndian, uint32(len(chunk0)))
|
_ = binary.Write(&buf, binary.BigEndian, uint32(len(chunk0)))
|
||||||
|
|||||||
Reference in New Issue
Block a user