From 33e7799fbb187203f568b47d1109cabeebf5e961 Mon Sep 17 00:00:00 2001 From: tfarley Date: Sun, 30 Apr 2017 00:12:11 -0700 Subject: [PATCH] Fix block-skip length logic for pcapng --- aclogview/PCapReader.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/aclogview/PCapReader.cs b/aclogview/PCapReader.cs index 8bef15e..da929f1 100644 --- a/aclogview/PCapReader.cs +++ b/aclogview/PCapReader.cs @@ -153,8 +153,9 @@ private static List loadPcapPacketRecords(BinaryReader binaryReade break; results.Add(packetRecord); - curPacket++; } + + curPacket++; } catch (Exception e) { @@ -172,6 +173,8 @@ private static PcapngBlockHeader readPcapngBlockHeader(BinaryReader binaryReader throw new InvalidDataException("Stream cut short (packet " + curPacket + "), stopping read: " + (binaryReader.BaseStream.Length - binaryReader.BaseStream.Position)); } + long blockStartPos = binaryReader.BaseStream.Position; + PcapngBlockHeader blockHeader = PcapngBlockHeader.read(binaryReader); if (blockHeader.capturedLen > 50000) @@ -182,7 +185,7 @@ private static PcapngBlockHeader readPcapngBlockHeader(BinaryReader binaryReader // Make sure there's enough room for an ethernet header if (blockHeader.capturedLen < 14) { - binaryReader.BaseStream.Position += blockHeader.capturedLen; + binaryReader.BaseStream.Position += blockHeader.blockTotalLength - (binaryReader.BaseStream.Position - blockStartPos); return null; } @@ -236,8 +239,9 @@ private static List loadPcapngPacketRecords(BinaryReader binaryRea break; results.Add(packetRecord); - curPacket++; } + + curPacket++; } catch (Exception e) {