waveterm/pkg/wshutil
Evan Simkowitz 1fc6dd7c1a
Fix code scanning alert no. 50: Size computation for allocation may overflow (#1088)
Fixes
[https://github.com/wavetermdev/waveterm/security/code-scanning/50](https://github.com/wavetermdev/waveterm/security/code-scanning/50)

To fix the problem, we need to ensure that the size computation for the
allocation does not overflow. This can be achieved by validating the
length of `barr` before performing the arithmetic operation. We will set
a maximum allowable size for `barr` to ensure that the sum of
`oscPrefixLen(oscNum)` and `len(barr)` does not exceed the maximum value
for an `int`.

1. Define a maximum allowable size for `barr` (e.g., 64 MB).
2. Check the length of `barr` against this maximum size before
performing the allocation.
3. If `barr` exceeds the maximum size, return an error.


_Suggested fixes powered by Copilot Autofix. Review carefully before
merging._

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2024-10-21 14:05:52 -07:00
..
wshadapter.go update all gopkg imports (#330) 2024-09-05 14:25:45 -07:00
wshcmdreader.go switch from 'main' to 'term' for main terminal blockfile 2024-08-12 15:53:34 -07:00
wshevent.go Migrate websocket eventbus messages to wps (#367) 2024-09-11 18:03:55 -07:00
wshproxy.go update all gopkg imports (#330) 2024-09-05 14:25:45 -07:00
wshrouter.go fix websocket reconnect error (#1064) 2024-10-18 12:05:20 -07:00
wshrpc.go Migrate websocket eventbus messages to wps (#367) 2024-09-11 18:03:55 -07:00
wshrpcio.go Fix code scanning alert no. 50: Size computation for allocation may overflow (#1088) 2024-10-21 14:05:52 -07:00
wshutil.go Fix code scanning alert no. 50: Size computation for allocation may overflow (#1088) 2024-10-21 14:05:52 -07:00