Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
uevent: fix crash on read errors
Browse files Browse the repository at this point in the history
The bufio package does not accept negative read count. Upon error,
reset the negative count before returning the result to bufio package.

Fixes: #366

Signed-off-by: Peng Tao <[email protected]>
  • Loading branch information
bergwolf committed Sep 13, 2018
1 parent 7caf1c8 commit 2b89a0a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/uevent/uevent.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ func NewReaderCloser() (io.ReadCloser, error) {

// Read implements reading function for uevent.
func (r *ReaderCloser) Read(p []byte) (int, error) {
return unix.Read(r.fd, p)
count, err := unix.Read(r.fd, p)
if count < 0 && err != nil {
count = 0
}
return count, err
}

// Close implements closing function for uevent.
Expand Down

0 comments on commit 2b89a0a

Please sign in to comment.