-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
This is the current code that is provided for the postamble check:
// check for a postamble sequence byte
if (b != postamble[postambleCounter]) {
postambleCounter = 0;
}
else {
++postambleCounter;
}
So let's pretend there accidentaly have been several bytes that matched the
beginning of the postamble. Then there is byte x which does not match anymore
(because we've matched data agains the postamble until now). So currently the
library will throw away this byte x and continue to check x+1. But what if byte
x has been the correct beginning of the postamble?
This leads to the, I grant, very rare case that the postamble will not be
recognized.
I would suggest following fix:
// check for a postamble sequence byte
if (b != postamble[postambleCounter])
{
// the byte that failed could be the beginning
// of a postamble sequence again ...
if (b == postamble[0])
{
postambleCounter = 1;
}
else
{
postambleCounter = 0;
}
}
else
{
++postambleCounter;
}
Original issue reported on code.google.com by floschn...@gmail.com on 19 Sep 2013 at 1:26