Catch buffer exceptions in the Lua sandboxes
This change ensures that the notification and rabbitmq decoders won't crash when they process excessive payload. Change-Id: I67e2dd8a03bdce4b7e72e1f981e61f518bc8778e Closes-Bug: #1504141
This commit is contained in:
parent
9316c2a2d8
commit
2483942415
|
@ -106,6 +106,10 @@ local include_full_notification = read_config("include_full_notification") or fa
|
||||||
|
|
||||||
function process_message ()
|
function process_message ()
|
||||||
local data = read_message("Payload")
|
local data = read_message("Payload")
|
||||||
|
if string.len(data) > 63000 then
|
||||||
|
-- See bug #1504141
|
||||||
|
return -1
|
||||||
|
end
|
||||||
local ok, notif = pcall(cjson.decode, data)
|
local ok, notif = pcall(cjson.decode, data)
|
||||||
if not ok then
|
if not ok then
|
||||||
return -1
|
return -1
|
||||||
|
@ -114,7 +118,10 @@ function process_message ()
|
||||||
if include_full_notification then
|
if include_full_notification then
|
||||||
msg.Payload = data
|
msg.Payload = data
|
||||||
else
|
else
|
||||||
msg.Payload = cjson.encode(notif.payload)
|
ok, msg.Payload = pcall(cjson.encode, notif.payload)
|
||||||
|
if not ok then
|
||||||
|
msg.Payload = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
msg.Fields = {}
|
msg.Fields = {}
|
||||||
|
@ -144,6 +151,6 @@ function process_message ()
|
||||||
end
|
end
|
||||||
utils.inject_tags(msg)
|
utils.inject_tags(msg)
|
||||||
|
|
||||||
inject_message(msg)
|
pcall(inject_message, msg)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -67,6 +67,6 @@ function process_message ()
|
||||||
msg.Fields.programname = 'rabbitmq'
|
msg.Fields.programname = 'rabbitmq'
|
||||||
utils.inject_tags(msg)
|
utils.inject_tags(msg)
|
||||||
|
|
||||||
inject_message(msg)
|
pcall(inject_message, msg)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue