Skip to content

Commit

Permalink
Remove fixed length read to prevent crash if src is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Yilun <[email protected]>
  • Loading branch information
yilunzhang committed Sep 14, 2018
1 parent 634edc0 commit f685083
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion consensus/ising/proposercache.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (pc *ProposerCache) Add(height uint32, votingContent voting.VotingContent)
return
}
var id uint64
err = binary.Read(bytes.NewBuffer(chordID[:8]), binary.LittleEndian, &id)
err = binary.Read(bytes.NewBuffer(chordID), binary.LittleEndian, &id)
if err != nil {
log.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion net/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func InitNode(pubKey *crypto.PubKey, ring *chord.Ring) Noder {
}
n.chordAddr = chordVnode.Id

err = binary.Read(bytes.NewBuffer(n.chordAddr[:8]), binary.LittleEndian, &(n.id))
err = binary.Read(bytes.NewBuffer(n.chordAddr), binary.LittleEndian, &(n.id))
if err != nil {
log.Error(err)
}
Expand Down

0 comments on commit f685083

Please sign in to comment.