Scripting: Re-fix some Lua string handling (fixes #2877)

This commit is contained in:
Vicki Pfau 2023-04-10 03:02:51 -07:00
parent dfb6055ae4
commit 3f108aae75
1 changed files with 5 additions and 1 deletions

View File

@ -911,7 +911,11 @@ bool _luaLoad(struct mScriptEngineContext* ctx, const char* filename, struct VFi
lastSlash = lastBackslash;
}
if (lastSlash) {
strlcpy(dirname, filename, lastSlash - filename);
size_t len = lastSlash - filename + 1;
if (sizeof(dirname) < len) {
len = sizeof(dirname);
}
strlcpy(dirname, filename, len);
}
snprintf(name, sizeof(name), "@%s", filename);
}