Skip to content

Commit

Permalink
Merge pull request #23 from ngie-eign/fix-gcc-compile
Browse files Browse the repository at this point in the history
Resolve a benign buffer overrun issue
  • Loading branch information
ngie-eign authored Dec 1, 2024
2 parents b9e865d + a4f3abb commit 0334a24
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ call_cxx_function_from_c(lutok::cxx_function function,
lutok::state state = lutok::state_c_gate::connect(raw_state);
return function(state);
} catch (const std::exception& e) {
std::strncpy(error_buf, e.what(), sizeof(error_buf));
std::strncpy(error_buf, e.what(), sizeof(error_buf) - 1);
} catch (...) {
std::strncpy(error_buf, "Unhandled exception in Lua C++ hook",
sizeof(error_buf));
sizeof(error_buf) - 1);
}
error_buf[sizeof(error_buf) - 1] = '\0';
// We raise the Lua error from outside the try/catch context and we use
Expand Down

0 comments on commit 0334a24

Please sign in to comment.