add lk console command with PortAudio + WebRTC AEC#775
Closed
theomonnom wants to merge 2 commits intomainfrom
Closed
add lk console command with PortAudio + WebRTC AEC#775theomonnom wants to merge 2 commits intomainfrom
lk console command with PortAudio + WebRTC AEC#775theomonnom wants to merge 2 commits intomainfrom
Conversation
cd5d7e2 to
9563002
Compare
bcherry
reviewed
Mar 3, 2026
matkam
approved these changes
Mar 30, 2026
| return fmt.Errorf("ipc: marshal: %w", err) | ||
| } | ||
|
|
||
| buf := make([]byte, 4+len(data)) |
Check failure
Code scanning / CodeQL
Size computation for allocation may overflow High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 hour ago
In general, the fix is to ensure that the size used in the allocation (4 + len(data)) cannot overflow the int type and is within an acceptable bound. This means validating len(data) before performing the addition and before allocating the buffer.
The best way to fix this here, without changing existing functionality, is:
- Reuse the existing
maxMessageSizebound (1MB) to constrain the size of serialized messages on the write side as well as the read side. This keeps the IPC protocol symmetric: you cannot send larger messages than you are willing to receive. - In
WriteProto, afterproto.Marshal(msg)succeeds, checklen(data):- If
len(data) > maxMessageSize, return an error likeipc: message too large: %d bytes. - This implies
4 + len(data)is at most4 + maxMessageSize, which is safely withinintlimits on all supported Go architectures and also belowmath.MaxUint32, consistent with the 4‑byte length prefix.
- If
- Because the bound is small (1MB), we do not need additional explicit overflow arithmetic guards; the inequality check is sufficient to guarantee that
4 + len(data)cannot overflow.
Concretely, in pkg/ipc/ipc.go, in WriteProto between lines 17–22, insert a size check on len(data) before computing buf := make([]byte, 4+len(data)). No new imports or helper functions are required.
Suggested changeset
1
pkg/ipc/ipc.go
| @@ -18,6 +18,9 @@ | ||
| if err != nil { | ||
| return fmt.Errorf("ipc: marshal: %w", err) | ||
| } | ||
| if len(data) > maxMessageSize { | ||
| return fmt.Errorf("ipc: message too large: %d bytes", len(data)) | ||
| } | ||
|
|
||
| buf := make([]byte, 4+len(data)) | ||
| binary.BigEndian.PutUint32(buf[:4], uint32(len(data))) |
Copilot is powered by AI and may make mistakes. Always verify output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.