Skip to content

Commit

Permalink
Log cleanup and fixed a nil pointer dereference error.
Browse files Browse the repository at this point in the history
  • Loading branch information
awgh committed May 13, 2020
1 parent ad800cd commit 8e12411
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
7 changes: 5 additions & 2 deletions pipes_notwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ func handleDryConnection(buff bytes.Buffer, config *bj.BinjectConfig) {
i, err := Inject(&buff, config)
if err != nil {
log.Printf("Error injecting: %v\n", err)
return
}
if i != nil {
lastBytes = i.Bytes()
log.Println("Set lastBytes: ", len(lastBytes))
}
log.Println("Set lastBytes: ", len(lastBytes))
lastBytes = i.Bytes()
}
21 changes: 14 additions & 7 deletions pipes_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,23 @@ func handleDryConnection(conn net.Conn, config *bj.BinjectConfig) {
r := bufio.NewReader(conn)
b, err := ioutil.ReadAll(r)
if err != nil {
log.Fatalf("Error reading from connection: %v", err)
log.Printf("Error reading from connection: %v", err)
return
}

bb := bytes.NewBuffer(b)
i, err := Inject(bb, config)
if err != nil {
log.Fatalf("Error injecting: %v", err)
log.Printf("Error injecting: %v", err)
return
}
if i != nil {
lastBytes = i.Bytes()
log.Println("Set lastBytes: ", len(lastBytes))
}
log.Println("Set lastBytes: ", len(lastBytes))
lastBytes = i.Bytes()
if err := conn.Close(); err != nil {
log.Fatalf("Error closing server side of connection: %v", err)
log.Printf("Error closing server side of connection: %v", err)
return
}
}

Expand All @@ -85,11 +90,13 @@ func handleWetConnection(conn net.Conn) {
log.Println("Wrote wet bytes: ", len(lastBytes))

if err != nil {
log.Fatalf("Error on writing to pipe: %v", err)
log.Printf("Error on writing to pipe: %v", err)
return
}

if err := conn.Close(); err != nil {
log.Fatalf("Error closing server side of connection: %v", err)
log.Printf("Error closing server side of connection: %v", err)
return
}
lastBytes = nil
}

0 comments on commit 8e12411

Please sign in to comment.