Error-proofing dissector and packet_out recursive
diff --git a/wireshark_gen/templates/openflow.lua b/wireshark_gen/templates/openflow.lua
index 3f86684..de7eb11 100644
--- a/wireshark_gen/templates/openflow.lua
+++ b/wireshark_gen/templates/openflow.lua
@@ -130,6 +130,9 @@
 :: include('_oftype_readers.lua')
 
 function dissect_of_message(buf, root)
+    if buf:len() < 2 then
+        return "Unknown OF message", "Dissection error"
+    end
     local reader = OFReader.new(buf)
     local subtree = root:add(p_of, buf(0))
     local version_val = buf(0,1):uint()
@@ -138,6 +141,8 @@
     local protocol = "OF ?"
     if openflow_versions[version_val] then
         protocol = "OF " .. openflow_versions[version_val]
+    else
+        return "Unknown protocol", "Dissection error"
     end
 
     local info = "unknown"
@@ -171,6 +176,10 @@
             pkt.cols.protocol:append(protocol)
             pkt.cols.info:append(info)
             offset = offset + msg_len
+            if msg_len == 0 then
+                offset = buf:len()
+                break
+            end
         else
             -- we don't have all of length field yet
             pkt.desegment_len = DESEGMENT_ONE_MORE_SEGMENT