Browse Source

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
tags/0.7-eol^0
Simon Pasquier 3 years ago
parent
commit
2483942415

+ 9
- 2
deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/notification.lua View File

@@ -106,6 +106,10 @@ local include_full_notification = read_config("include_full_notification") or fa
106 106
 
107 107
 function process_message ()
108 108
     local data = read_message("Payload")
109
+    if string.len(data) > 63000 then
110
+        -- See bug #1504141
111
+        return -1
112
+    end
109 113
     local ok, notif = pcall(cjson.decode, data)
110 114
     if not ok then
111 115
         return -1
@@ -114,7 +118,10 @@ function process_message ()
114 118
     if include_full_notification then
115 119
         msg.Payload = data
116 120
     else
117
-        msg.Payload = cjson.encode(notif.payload)
121
+        ok, msg.Payload = pcall(cjson.encode, notif.payload)
122
+        if not ok then
123
+            msg.Payload = nil
124
+        end
118 125
     end
119 126
 
120 127
     msg.Fields = {}
@@ -144,6 +151,6 @@ function process_message ()
144 151
     end
145 152
     utils.inject_tags(msg)
146 153
 
147
-    inject_message(msg)
154
+    pcall(inject_message, msg)
148 155
     return 0
149 156
 end

+ 1
- 1
deployment_scripts/puppet/modules/lma_collector/files/plugins/decoders/rabbitmq.lua View File

@@ -67,6 +67,6 @@ function process_message ()
67 67
     msg.Fields.programname = 'rabbitmq'
68 68
     utils.inject_tags(msg)
69 69
 
70
-    inject_message(msg)
70
+    pcall(inject_message, msg)
71 71
     return 0
72 72
 end

Loading…
Cancel
Save