Audit finding (sweep1-runtime, /Users/server/Development/external-tools/reports/protobufjs/sweep1-runtime.md). Wire-correctness bug.
Evidence: src/decoder.js:286 generates r.skipType(t&7,q,t) when the message type has zero fields. The t>>>=3 reassignment (decoder.js:69) only happens inside if (mtype.fieldsArray.length), so the third argument (fieldNumber) is the full tag, not the field number. Reader.skipType (src/reader.js:822) compares the nested end tag's field number against it and always mismatches → throws.
Repro (verified):
const pb = require('./src/index.js');
const root = pb.Root.fromJSON({ nested: { T: { fields: {} }, U: { fields: { x: { type:'int32', id:1 } } } } });
const bytes = Uint8Array.from([0x0b, 0x0c]); // group f1 + matching end tag
root.lookupType('T').decode(bytes); // throws "invalid end group tag"
root.lookupType('U').decode(bytes); // OK
Decision question: Adopt the one-line fix (t>>>3 when no fields) plus a regression test with the two-byte repro?
Audit finding (sweep1-runtime, /Users/server/Development/external-tools/reports/protobufjs/sweep1-runtime.md). Wire-correctness bug.
Evidence: src/decoder.js:286 generates
r.skipType(t&7,q,t)when the message type has zero fields. Thet>>>=3reassignment (decoder.js:69) only happens insideif (mtype.fieldsArray.length), so the third argument (fieldNumber) is the full tag, not the field number. Reader.skipType (src/reader.js:822) compares the nested end tag's field number against it and always mismatches → throws.Repro (verified):
Decision question: Adopt the one-line fix (
t>>>3when no fields) plus a regression test with the two-byte repro?