dbus-pcap: Use MalformedPacketError instead of assert
This allows us to continue in the face of bad packets while still
reporting them.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ia85d63bc32af969e3673276e702c27a42ac4ce94
diff --git a/dbus-pcap/dbus-pcap b/dbus-pcap/dbus-pcap
index 8108ac8..11ae253 100755
--- a/dbus-pcap/dbus-pcap
+++ b/dbus-pcap/dbus-pcap
@@ -187,9 +187,10 @@
remaining = bytes(self.stream)
offset = self.offset
self.offset += len(remaining)
- assert self.offset - self.stash[1] == len(self.stash[0]), \
- ("(self.offset - self.stash[1]): %d, len(self.stash[0]): %d"
- % (self.offset - self.stash[1], len(self.stash[0])))
+ if self.offset - self.stash[1] != len(self.stash[0]):
+ print("(self.offset - self.stash[1]): %d, len(self.stash[0]): %d"
+ % (self.offset - self.stash[1], len(self.stash[0])), file=sys.stderr)
+ raise MalformedPacketError
return remaining, offset
def dump(self):