
Dear Scott,
In message 5000AB43.6090406@freescale.com you wrote:
You are interpreting something which can be random data.
if (e.version == 0) crc_offset = 0x72;
So here we're reading the 'version' field before we validate the data, because we need to check the version to know where the CRC is.
Argh. More crap ...
And how would you do it? You have to look at *something* first, and whatever that is could be a coincidence if you think people are going to stuff arbitrary data into the EEPROM.
If you cannot avoid using binary data structures you must make sure the design allows extensions which do not break the design. This was attempted here (CRC at fixed position 0xFC), which is supposed to be "at the end" - unless the EEPROM size changes one day.
Accessing _any_ data fields in the binary structure must always be done only _after_ the CRC has been verified. It makes zero sense to try to interpret a version field without knowing if it is valid at all.
Such code shows undefined behaviour. You may argument that the likelyhood of a false match is small, but this doesn't matter: it's still undefined behaviour.
With all the previous explanations already given (only very fewsystems affected) it is best to remove all this crap, and provide a manual recovery tool (to be run under close supervision of the user).
Best regards,
Wolfgang Denk