1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-12-25 09:58:04 +11:00

Do not unregister listeners on unexpected data

If a registered event listener callback returns `false`, the listener is
unregistered. A network packet arriving on a different port, or a
message with a missing part, should not cause the syslog system to shut
down. Return `nil` instead of `false` if those sanity checks fail, to
keep the listener registered.
This commit is contained in:
Christopher Head 2021-01-22 19:21:23 -08:00
parent 4c462a5d4e
commit 074a980d81
No known key found for this signature in database
GPG Key ID: 889FF36E814738DE

View File

@ -69,15 +69,15 @@ local function wentry(_,msg,level,service,host)
end
local function remote_listener(_,from,port,data)
if port ~= cfg.port then return false end
if port ~= cfg.port then return end
local service, level, msg = data:match("(.-)\t(%d)\t(.+)")
if not service or not level or not msg then return false end
if not service or not level or not msg then return end
msg, level, service = tostring(msg),tonumber(level),tostring(service)
wentry(nil,msg,level,service,from)
end
local function local_listener(_,msg,level,service)
if not service or not level or not msg then return false end
if not service or not level or not msg then return end
msg, level, service = tostring(msg),tonumber(level),tostring(service)
wentry(nil,msg,level,service,hostname)
end