Skip to content

lua52-sys: fix lua_Debug layout and lua_getctx signature to match - #227

Open
argusSecurityBot wants to merge 1 commit into
tomaka:masterfrom
argusSecurityBot:fix/lua52-sys-debug-layout-and-getctx-signature
Open

argusSecurityBot wants to merge 1 commit into
tomaka:masterfrom
argusSecurityBot:fix/lua52-sys-debug-layout-and-getctx-signature

Conversation

@argusSecurityBot

Copy link
Copy Markdown

The #[repr(C)] lua_Debug binding omitted the trailing private i_ci field that Lua 5.2's real struct ends with (struct CallInfo *i_ci). The struct was 120 bytes where C's is 128, so lua_getstack's store to ar->i_ci wrote 8 bytes past a Rust-sized lua_Debug. Add the trailing field; the struct is now 128 bytes, matching sizeof(lua_Debug) in lua.h.

lua_getctx was declared taking ctx by value (c_int) where the C function is int lua_getctx(lua_State *L, int *ctx) and writes *ctx. Passing an integer made C treat it as an address and store through it. Declare ctx as *mut c_int.

… 5.2 ABI

The #[repr(C)] lua_Debug binding omitted the trailing private i_ci field
that Lua 5.2's real struct ends with (struct CallInfo *i_ci). The struct
was 120 bytes where C's is 128, so lua_getstack's store to ar->i_ci wrote
8 bytes past a Rust-sized lua_Debug. Add the trailing field; the struct is
now 128 bytes, matching sizeof(lua_Debug) in lua.h.

lua_getctx was declared taking ctx by value (c_int) where the C function is
int lua_getctx(lua_State *L, int *ctx) and writes *ctx. Passing an integer
made C treat it as an address and store through it. Declare ctx as *mut c_int.
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.

1 participant