From ff8631d1b809fd1b5c05065850f59e73d2489dda Mon Sep 17 00:00:00 2001
From: Steve <steved@ssec.wisc.edu>
Date: Wed, 1 Mar 2017 20:30:54 +0000
Subject: [PATCH] FIX: merging was broken for corrupt packet groups

corrupt session groups can have packet files with multiple APIDs
we handel this by filtering these out and skipping to the next stamp
---
 edosl0util/merge.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/edosl0util/merge.py b/edosl0util/merge.py
index c55dd67..20eebce 100644
--- a/edosl0util/merge.py
+++ b/edosl0util/merge.py
@@ -64,6 +64,11 @@ def read_packet_index(stream):
             LOG.info('dropped %d leading packets', count)
 
         while True:
+            if not packet.stamp:
+                # corrupt packet groups can cause apid mismatch
+                # so skip until we get to the next group
+                packet = stream.next()
+                continue
             ptr = _Ptr(
                 stream.file,
                 stamp=packet.stamp,
@@ -75,6 +80,10 @@ def read_packet_index(stream):
             # collect all packets for this stamp/group
             packet = stream.next()
             while not packet.stamp:
+                # Bail if we're collecting group packets and apids don't match
+                # This means group is corrupt
+                if ptr.apid != packet.apid:
+                    break
                 ptr.size += packet.size
                 ptr.count += 1
                 packet = stream.next()
-- 
GitLab