diff --git a/sys/apis/socket.lua b/sys/apis/socket.lua index 6cfca6a..7db64ae 100644 --- a/sys/apis/socket.lua +++ b/sys/apis/socket.lua @@ -128,6 +128,7 @@ function Socket.connect(host, port) local e, id, sport, dport, msg = os.pullEvent() if e == 'modem_message' and sport == socket.sport and + type(msg) == 'table' and msg.dhost == socket.shost then os.cancelTimer(timerId) @@ -183,7 +184,8 @@ function Socket.server(port) local _, _, sport, dport, msg = os.pullEvent('modem_message') if sport == port and - msg and type(msg) == 'table' and + msg and + type(msg) == 'table' and msg.dhost == os.getComputerID() and msg.type == 'OPEN' then diff --git a/sys/network/redserver.lua b/sys/network/redserver.lua index f4f9351..fda019c 100644 --- a/sys/network/redserver.lua +++ b/sys/network/redserver.lua @@ -83,11 +83,15 @@ Event.on('modem_message', function(_, _, dport, dhost, request) if dport == 80 and dhost == computerId and type(request) == 'table' then if request.method == 'GET' then local query + if not request.path or type(request.path) ~= 'string' then + return + end local path = request.path:gsub('%?(.*)', function(v) query = parseQuery(v) return '' end) if fs.isDir(path) then + -- TODO: more validation modem.transmit(request.replyPort, request.replyAddress, { statusCode = 200, contentType = 'table/directory',