Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for digiline message field type #670

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Emojigit
Copy link
Member

This PR fixes a fatal error: if a malformed digiline table is passed into a node detector, the server may crash because of a mismatched data type.

For example, this weird backtrace happened because technic is sending "malformed" tables:

ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '??' in callback node_on_timer(): $HOME/.minetest/mods/mesecons/mesecons_detector/init.lua:63: bad argument #2 to 'set_string' (string expected, got table)
ERROR[Main]: stack traceback:
ERROR[Main]:       [C]: in function 'set_string'
ERROR[Main]:       $HOME/.minetest/mods/mesecons/mesecons_detector/init.lua:63: in function 'action'
ERROR[Main]:       $HOME/.minetest/mods/digicontrol/override.lua:45: in function 'transmit'
ERROR[Main]:       $HOME/.minetest/mods/digicontrol/override.lua:78: in function 'receptor_send'
ERROR[Main]:       ...test/mods/technic/technic/machines/switching_station.lua:112: in function <...test/mods/technic/technic/machines/switching_station.lua:87>

@@ -223,10 +223,10 @@ local node_detector_digiline = {

if type(msg) == "table" then
if msg.distance or msg.scanname then
if msg.distance then
if msg.distance and type(msg.distance) == "string" then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below: superfluous msg.distance check because type would return "nil" in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants