In the case a packet ends
<op n><len><data>
<op n><len><data>
<op 255>
there will only be 1 byte (the <op 255>) after going round the loop
twice. Previously this would have failed the test (end - next) < 2
without having detected that the option code has changed.
q = concat_buffer;
for (next = data; next < end; next += 2 + next[1]) {
- if ((end - next) < 2) return -1;
+ if (next >= end) return -1;
if (next[0] != data[0]) break;
+ if ((end - next) < 2) return -1;
if ((next + 2 + next[1]) > end) return -1;
if ((size_t) (q + next[1] - concat_buffer) > sizeof(concat_buffer)) return -1;