Potential buffer overrun in script_interface.cpp, copy_lua_variable_to_c

Potential buffer overrun in script_interface.cpp, copy_lua_variable_to_c

Anonymous
Not applicable
543 Views
2 Replies
Message 1 of 3

Potential buffer overrun in script_interface.cpp, copy_lua_variable_to_c

Anonymous
Not applicable

Hello,

 

if you're on a release build of Stringray and do a Lua::pushstring and the size of the string exceeds the maximum string length you'll get a buffer overrun in script_interface.cpp, copy_lua_variable_to_c. The code in question does a strcpy  but the XENSURE macro will expand to nothing, so there's nothing to catch this. 

 

 

Thanks.

 

 

 

 

Reply
Reply
0 Likes
544 Views
2 Replies
Replies (2)
Message 2 of 3

__ben__
Alumni
Alumni

Thank you for reporting this. Can you please post a LUA code snippet that triggers this and also note which version of Stingray you are using? I'll try and reproduce the problem and include a fix in a future release.

Reply
Reply
0 Likes
Message 3 of 3

Anonymous
Not applicable

Hi,

 

Not sure if you can trigger this from Lua. I'm seeing this issue being hit by C++ plugin that does a 

 

LuaApi::pushstring(lua_State *L, const char *s)

with a string whose size exceeds the max string. Perhaps the API contract is so that the client code is always responsible for providing strings that can fit in the buffer, hard to tell since there's no actual documentation for the API call. Either case the blind strcpy is a bit  unsafe.

 

EDIT:

 

Seems that 1.6 is the latest engine version with this problem, the later versions seem to either be refactored so that the code/problem in question is elsewhere or it doesn't exist at all. 

 

Reply
Reply
0 Likes