3 ms·
If something 'happens to match': Assuming only lengths, the packet length won't match - you'll reach the end of the structure before the end of the data. The
by Groxx 15y ago
If something 'happens to match':
Assuming only lengths, the packet length won't match - you'll reach the end of the structure before the end of the data. The point of all this is to validate before interpreting, so it fails validation, and no harm is done.
Assuming a \0 termination, which requires that it does not exist in the data (an escaping problem): there won't be a \0 after the should-be-last piece of metadata, so it fails validation, and no harm is done.
And all of this assumes you have a correctly-transmitted packet to begin with. What if you don't? If your spec+validator can't detect it, then you are introducing possible attack vectors - your tests must test wholly-invalid structures, which your validator must fail, to be 'safe'. I don't see how delimiters protect this any more than lengths, and they add complexity due to escaping (which I do think can be done safely + correctly, but we're also assuming they cannot be because that was essentially a claim in the video), and you must escape if you use delimiters and allow arbitrary data.