aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDS <ds.desour@proton.me>2023-03-27 20:01:05 +0200
committerGitHub <noreply@github.com>2023-03-27 20:01:05 +0200
commit2180dc14ef802961d50d5e5f7fccd2d3a2b9f647 (patch)
tree154c6fd30f847661082533ecb6bca6ddda196307
parentbaf99f826c6e35519f68b666c27af6953f295159 (diff)
downloadminetest-2180dc14ef802961d50d5e5f7fccd2d3a2b9f647.tar.xz
Fix safeLoadFile() skipping 2 chars too much from the shebang (#13310)
-rw-r--r--src/script/cpp_api/s_security.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/script/cpp_api/s_security.cpp b/src/script/cpp_api/s_security.cpp
index 09e971007..3bf8d1044 100644
--- a/src/script/cpp_api/s_security.cpp
+++ b/src/script/cpp_api/s_security.cpp
@@ -457,11 +457,10 @@ bool ScriptApiSecurity::safeLoadFile(lua_State *L, const char *path, const char
size_t start = 0;
int c = std::getc(fp);
if (c == '#') {
- // Skip the first line
- while ((c = std::getc(fp)) != EOF && c != '\n') {}
- if (c == '\n')
- std::getc(fp);
- start = std::ftell(fp);
+ // Skip the shebang line (but keep line-ending)
+ while (c != EOF && c != '\n')
+ c = std::getc(fp);
+ start = std::ftell(fp) - 1;
}
// Read the file