Skip to content

Commit 425f28d

Browse files
committed
[decoding] check unbounded access when reading Uint8Array
1 parent bb5b3de commit 425f28d

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ node_modules
66
*.d.ts.map
77
*/*.d.ts
88
*/*.d.ts.map
9+
next.md
10+
.playwright-mcp

‎decoding.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ export const clone = (decoder, newPos = decoder.pos) => {
103103
* @return {Uint8Array<Buf>}
104104
*/
105105
export const readUint8Array = (decoder, len) => {
106+
if (len < 0 || len > decoder.arr.length - decoder.pos) {
107+
throw errorUnexpectedEndOfArray
108+
}
106109
const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len)
107110
decoder.pos += len
108111
return view

0 commit comments

Comments
 (0)