fix(proton): accept sign-extended uint32 field values

This commit is contained in:
DrSmoothl committed 2026-07-10 18:20:11 +08:00
1 parent c04864dd21
commit b53004ee23
4 files changed
+139 -4

No files matched your search

+7
View File
@@ -117,6 +117,13 @@ function __readVarint64(data, offset, end) {
}
throw new Error('protobuf uint64 varint overflow');
}
function __readVarint32Value(data, offset, end) {
const [value, next] = __readVarint64(data, offset, end);
if (value > 0xffffffffn && value < 0xffffffff80000000n) {
throw new Error('protobuf uint32 field varint overflow');
}
return [Number(BigInt.asUintN(32, value)), next];
}
function __skipVarint(data, offset, end) {
for (let i = 0; i < 10; i++) {
if (offset >= end) throw new Error('protobuf truncated varint');