Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug where snaplen = 0 #462

Merged
merged 2 commits into from
Mar 25, 2020
Merged

fix bug where snaplen = 0 #462

merged 2 commits into from
Mar 25, 2020

Conversation

mccanne
Copy link
Collaborator

@mccanne mccanne commented Mar 25, 2020

A pcap file with snaplen=0 means that there was no capture length
restriction and all packets are captured at full size. There was
a check inherited from gopacket that raised an error if the
captured length was larger than the snaplen, which is a bug for
snaplen=0. The fix is to change this check to check alsoo that
snaplen isn't zero.

A pcap file with snaplen=0 means that there was no capture length
restriction and all packets are captured at full size.  There was
a check inherited from gopacket that raised an error if the
captured length was larger than the snaplen, which is a bug for
snaplen=0.  The fix is to change this check to check alsoo that
snaplen isn't zero.
@mccanne mccanne requested a review from a team March 25, 2020 21:36
@@ -152,7 +152,7 @@ func (r *PcapReader) Read() ([]byte, BlockType, error) {
}
caplen := int(r.byteOrder.Uint32(hdr[8:12]))
fullLength := int(r.byteOrder.Uint32(hdr[12:16]))
if caplen > int(r.snaplen) {
if int(r.snaplen) != 0 && caplen > int(r.snaplen) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it doesn't look like you need the int() cast just to check against 0?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@mccanne mccanne merged commit 7d4f0ac into master Mar 25, 2020
@mccanne mccanne deleted the zero-snaplen branch March 25, 2020 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants