mirror of
https://git.um-react.app/um/um-react.git
synced 2026-11-27 23:56:59 +00:00
fix: clamp payload length in MMKVParser to prevent overflow
- Updated the MMKVParser to ensure the calculated length does not exceed the DataView's byte length. - Added tests to verify behavior at the payload boundary, including cases for oversized payloads and exact matches.
This commit is contained in:
1 parent
10e857a903
commit
75d786c747
2 files changed
+56
-1
No files matched your search
@@ -7,7 +7,7 @@ export class MMKVParser {
|
||||
|
||||
constructor(private view: DataView<ArrayBuffer>) {
|
||||
const payloadLength = view.getUint32(0, true);
|
||||
this.length = 4 + payloadLength;
|
||||
this.length = Math.min(4 + payloadLength, view.byteLength);
|
||||
|
||||
// skip unused str
|
||||
this.readInt();
|
||||
|
||||
Reference in new issue
Block a user