From 71caaf180c88de84975e7a6c61ccffe22b03ddea Mon Sep 17 00:00:00 2001 From: Radicalicious Date: Tue, 2 Aug 2022 20:59:13 -0500 Subject: [PATCH] Fix mapmusname not overwriting Lua-provided strings --- src/lua_script.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lua_script.c b/src/lua_script.c index a36e5bf98..44fcbe601 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -441,12 +441,13 @@ int LUA_CheckGlobals(lua_State *L, const char *word) const char *str = luaL_checklstring(L, 2, &strlength); if (strlength > 6) - return luaL_error(L, "string length out of range (maximum 6 characters)"); + LUA_UsageWarning(L, "mapmusname: Music name too long - truncated to six characters."); if (strlen(str) < strlength) return luaL_error(L, "string must not contain embedded zeros!"); - strncpy(mapmusname, str, strlength); + + strlcpy(mapmusname, str, sizeof mapmusname); } else if (fastcmp(word, "mapmusflags")) mapmusflags = (UINT16)luaL_checkinteger(L, 2);