-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't crash when the packet length is zero
Also, report EOF in the middle of a packet as a protocol error rather than EOF.
- Loading branch information
greatroar
committed
Oct 30, 2020
1 parent
3c22ebf
commit 96cf5ed
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build gofuzz | ||
|
||
package sftp | ||
|
||
import "bytes" | ||
|
||
type sink struct{} | ||
|
||
func (*sink) Close() error { return nil } | ||
func (*sink) Write(p []byte) (int, error) { return len(p), nil } | ||
|
||
var devnull = &sink{} | ||
|
||
// To run: go-fuzz-build && go-fuzz | ||
func Fuzz(data []byte) int { | ||
c, err := NewClientPipe(bytes.NewReader(data), devnull) | ||
if err != nil { | ||
return 0 | ||
} | ||
c.Close() | ||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters