fix(plugins): guard against integer overflow in callPluginFunctionRaw frame allocation

Add overflow check before allocating the input frame buffer to prevent
potential integer wraparound on 32-bit platforms (flagged by github-advanced-security).
This commit is contained in:
Deluan 2026-02-13 15:55:43 -05:00
parent 425fe862ba
commit fc113d1dc6

View File

@ -130,7 +130,11 @@ func callPluginFunctionRaw[I any, O any](
if err != nil {
return result, fmt.Errorf("failed to marshal input: %w", err)
}
frame := make([]byte, 4+len(jsonBytes)+len(rawInputBytes))
totalSize := 4 + len(jsonBytes) + len(rawInputBytes)
if totalSize < len(jsonBytes) || totalSize < len(rawInputBytes) {
return result, fmt.Errorf("input frame too large")
}
frame := make([]byte, totalSize)
binary.BigEndian.PutUint32(frame[:4], uint32(len(jsonBytes)))
copy(frame[4:4+len(jsonBytes)], jsonBytes)
copy(frame[4+len(jsonBytes):], rawInputBytes)