2ed0f4b5
wire: validate field number and minimal encoding in decode_tag
Three checks added on the multi-byte path: 1. Field number must be > 0 (IllegalZeroFieldNum_Case_0/1/3). 2. Field number must fit in 29 bits per the protobuf spec (BadTag_FieldNumberSlightlyTooHigh, BadTag_FieldNumberTooHigh). 3. Tag varint must be minimally encoded — a trailing 0 byte with more than one byte read is overlong (BadTag_OverlongVarint). The field-number check runs on bit ops over the uint64 cdata returned by decode_varint rather than after tonumber, otherwise field numbers above 2^32 alias into the valid range (e.g., fn=2^31+1 was being recovered as fn=1). The single-byte fast path picks up the field-zero check directly via the b >> 3 == 0 condition. Drops 6 entries from test/conformance/known_failures.txt and adds 4 regression tests pinning each rejection path.
Eugene Blikh <bigbes@gmail.com> — 2026-05-15 21:41:59 UTC
Commit 2ed0f4b5b17a1235cbcef16005370d430b2b5424 —
view raw patch
Parent(s):
849b7662
| File | Status | + | − |
|---|---|---|---|
runtime/pb/wire.lua
|
M | +21 | -5 |
test/conformance/known_failures.txt
|
M | -6 | |
test/conformance_test.lua
|
M | +34 |