ComputerCraft

ComputerCraft

21M Downloads

Rednet crash using malformed dns message.

Wojbie opened this issue ยท 5 comments

commented

In line 245 of rednet api:

if sProtocol == "dns" and tMessage.sType == "lookup" then

If rednet is open and computer receives message on sProtocol = "dns" but tMessage if different type from table (like string or number) this line crashes/turns off the computer by causing rednet.run to error.
It can be simply fixed by adding type() test in said line. Per example:

if sProtocol == "dns" and type(tMessage) == "table" and tMessage.sType == "lookup" then
commented

Fixed for 1.76pr1

commented

In version 1.76pr3 the rednet file was returned to state before the fix.
So Unfixed as of 1.76pr3?

commented

yea.. code you posted is not fixed one. line 245 is:

if sProtocol == "dns" and tMessage.sType == "lookup" then

and that allows dns message that is not a table to cause crash.
IF tMessage is a number then it crashes cause you are trying to treat number as table.

This avoids problem:

if sProtocol == "dns" and type(tMessage) == "table" and tMessage.sType == "lookup" then

Edit. Extracted from clean download of pr3: http://pastebin.com/xTXvNmyE
Line 245 is still broken.

commented

I see the problem: there were two lines which needed fixing, one on line 245, and one on line 198. The two lines of code were very similar, so reading the logs seems to have made us both confused. I've now fixed the second bug.