mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-11 11:57:12 +02: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
1 changed files with 5 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue