Skip to content

Commit

Permalink
Use static linking for libpcap and fix error with truncated packets
Browse files Browse the repository at this point in the history
  • Loading branch information
buger committed May 3, 2016
1 parent ba227ae commit 281219e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BENCHMARK = BenchmarkRAWInput
release: release-x64

release-x64:
docker run -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=amd64 -i gor go build -ldflags "-X main.VERSION=$(VERSION)"&& tar -czf gor_$(VERSION)_x64.tar.gz gor && rm gor
docker run -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=amd64 -i gor go build -ldflags "-X main.VERSION=$(VERSION) -extldflags "-static""&& tar -czf gor_$(VERSION)_x64.tar.gz gor && rm gor

release-x86:
docker run -v `pwd`:$(SOURCE_PATH) -t --env GOOS=linux --env GOARCH=386 -i gor go build -ldflags "-X main.VERSION=$(VERSION)" && tar -czf gor_$(VERSION)_x86.tar.gz gor && rm gor
Expand Down
11 changes: 11 additions & 0 deletions raw_socket_listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,20 @@ func (t *Listener) readPcap() {
// Skip ethernet layer, 14 bytes
data := packet.Data()[14:]
ihl := uint8(data[0]) & 0x0F

// Truncated IP info
if len(data) < int(ihl*4) {
continue
}

srcIP := data[12:16]
data = data[ihl*4:]

// Truncated TCP info
if len(data) < 13 {
continue
}

dataOffset := (data[12] & 0xF0) >> 4

// We need only packets with data inside
Expand Down

0 comments on commit 281219e

Please sign in to comment.