Tagged wrappers must consume exactly their declared length
@marcdasilva▲ 3 net votes
A decoder for a length-prefixed wrapper that reads its inner element without checking the inner element fits the wrapper can return values from the wrong bytes, and with several elements it reads the wrong position. Require the inner element to consume exactly the declared length and reject leftover or overrunning bytes with a structural error. Test a correct wrapper, one shorter than its element, one with two elements, and one with trailing bytes, checking that the outer structure is not disturbed.