[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Small inconsistency?
- From: Thomas Lauer <thomas.lauer@<a href="/cgi-bin/echo.cgi?virgin.net">...</a>>
- Date: Mon, 19 Mar 2007 16:25:35 +0000 (UTC)
Here's what appears to be an inconsistency in the Lua sources.
This comes from lua.h:
/* mark for precompiled code (`<esc>Lua') */
#define LUA_SIGNATURE "\033Lua"
In lundump.h, there's:
/* size of header of binary files */
#define LUAC_HEADERSIZE 12
And finally, from lundump.c:
static void LoadHeader(LoadState* S)
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
... as well as:
void luaU_header (char* h)
*h++=(char)*(char*)&x; /* endianness */
*h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
What happens if someone changes LUA_SIGNATURE in lua.h to something longer than
4 characters? Well, I did (after checking all obvious places where the
signature's used) and recompiled. To my surprise, the resulting luac executable
crashed... so I started looking at some less obvious places and found that these
functions in lundump.c simply suppose a signature length of 4 characters or less.
Perhaps there should be a warning in lua.h? Or somewhat more robust code in