Get the latest tech news

Recommendations for designing magic numbers of binary file formats


another day, another binary file format with a badly designed magic number not gonna call it out specifically but here are some RFC2119 MUSTs for magic number design: MUST be the very first N bytes in the file MUST be at least four bytes long, eight is better MUST include at least one byte with the high bit set MUST include a byte sequence that is invalid UTF-8 SHOULD include a zero byte, but you can usually get away with having that be part of the overall version number that immediately follows the magic number (did I mention that you really SHOULD put an overall version number right after the magic number, unless you know and have documented exactly why it's not necessary, e.g. PNG?) good examples: * PNG * ELF bad examples: * GIF * PE * PDF

Get the Android app

Or read this on Hacker News

Read more on:

Photo of recommendations

recommendations

Photo of Magic Numbers

Magic Numbers

Photo of binary file formats

binary file formats

Related news:

News photo

Meta AI will now use your Facebook and Instagram activity to inform its recommendations

News photo

Hypelist wants to break lists out of silos and put recommendations first

News photo

Instagram Tests Recommendations Reset for Fresh Start