Skip to content

Conversation

@graehl
Copy link
Contributor

@graehl graehl commented Mar 11, 2014

windows compile (MSVC2010) - std::min, WINBOOL typedef was needed for my compile on Visual Studio 2010

SetAlternateMagicBeforeVersion allows a second, customizable file header. I've been maintaining it locally and it would be nice to have it included in kpu:master (nice for me, at least).

@kpu
Copy link
Owner

kpu commented Mar 11, 2014

Kareem M. Darwish (kdarwish at qf.org.qa) encountered the OS X issue and reported that this fixed it on 3/31/2013. I don't have a Mac, so it's hard for me to retest these things.

I'm working on ACL short and hope you can wait until after the deadline. . . unsure I can endorse DRM though.

@kpu
Copy link
Owner

kpu commented Mar 17, 2014

I cherry-picked the std::min change in 032e60a and the WINBOOL typedef in an64cdb2220e251df3d2cd4c0b5fc58d77ed964708d . Hope it works on Windows now.

Here's a one-line change to allow both 'encrypted' and 'unenecrypted' formats to load. In binary_format.cc, change
if (!std::memcmp(memory.get(), &reference_header, sizeof(Sanity))) return true;
to
if (!std::memcmp((uint8_t*)memory.get() + strlen(kMagicBeforeVersion), &reference_header + strlen(kMagicBeforeVersion), sizeof(Sanity) - strlen(kMagicBeforeVersion))) return true;

It will lose some error handling, like detecting incomplete files quickly. But it still has a low collision probability due to the other magic bytes for endianness testing and will allow anybody to load LMs distributed by SDL/LW regardless of the magic bytes you use.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants