Skip to content

Commit

Permalink
Fix block-skip length logic for pcapng
Browse files Browse the repository at this point in the history
  • Loading branch information
tfarley committed Apr 30, 2017
1 parent 123192c commit 33e7799
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions aclogview/PCapReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ private static List<PacketRecord> loadPcapPacketRecords(BinaryReader binaryReade
break;

results.Add(packetRecord);
curPacket++;
}

curPacket++;
}
catch (Exception e)
{
Expand All @@ -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)
Expand All @@ -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;
}

Expand Down Expand Up @@ -236,8 +239,9 @@ private static List<PacketRecord> loadPcapngPacketRecords(BinaryReader binaryRea
break;

results.Add(packetRecord);
curPacket++;
}

curPacket++;
}
catch (Exception e)
{
Expand Down

0 comments on commit 33e7799

Please sign in to comment.