diff --git a/plugins/manager_call.go b/plugins/manager_call.go index fbd46eb52..6989b8c67 100644 --- a/plugins/manager_call.go +++ b/plugins/manager_call.go @@ -130,11 +130,11 @@ func callPluginFunctionRaw[I any, O any]( if err != nil { return result, fmt.Errorf("failed to marshal input: %w", err) } - totalSize := 4 + len(jsonBytes) + len(rawInputBytes) - if totalSize < len(jsonBytes) || totalSize < len(rawInputBytes) { + const maxFrameSize = 2 << 20 // 2 MiB + if len(jsonBytes) > maxFrameSize || len(rawInputBytes) > maxFrameSize { return result, fmt.Errorf("input frame too large") } - frame := make([]byte, totalSize) + frame := make([]byte, 4+len(jsonBytes)+len(rawInputBytes)) binary.BigEndian.PutUint32(frame[:4], uint32(len(jsonBytes))) copy(frame[4:4+len(jsonBytes)], jsonBytes) copy(frame[4+len(jsonBytes):], rawInputBytes)