mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
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:
parent
425fe862ba
commit
fc113d1dc6
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user