Skip to content

Postamble is not recognized #1

Description

@GoogleCodeExporter
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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions