Fix: increase Opus buffer size to 1500 bytes and add bounds check

This commit is contained in:
Alex P 2025-11-17 22:17:02 +02:00
parent 1e22e007ea
commit 9371868b14
1 changed files with 5 additions and 1 deletions

View File

@ -21,7 +21,7 @@ import (
) )
const ( const (
ipcMaxFrameSize = 1024 ipcMaxFrameSize = 1500
) )
type CgoSource struct { type CgoSource struct {
@ -184,6 +184,10 @@ func (c *CgoSource) ReadMessage() (uint8, []byte, error) {
return 0, nil, nil return 0, nil, nil
} }
if int(opusSize) > len(c.opusBuf) {
return 0, nil, fmt.Errorf("opus packet too large: %d > %d", opusSize, len(c.opusBuf))
}
return ipcMsgTypeOpus, c.opusBuf[:opusSize], nil return ipcMsgTypeOpus, c.opusBuf[:opusSize], nil
} }