Skip to content

Commit

Permalink
fix(debug): Check length of wal entry before parsing
Browse files Browse the repository at this point in the history
Check for the length of wal entry's data before parsing it for key
  • Loading branch information
ahsanbarkati authored Jun 16, 2021
2 parents 6d2d117 + 3c3bd5a commit bac8fbf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion dgraph/cmd/debug/wal.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ func printEntry(es raftpb.Entry, pending map[uint64]bool, isZero bool) {
defer func() {
fmt.Printf("%s\n", buf.Bytes())
}()

var key uint64
if len(es.Data) >= 8 {
key = binary.BigEndian.Uint64(es.Data[:8])
}
fmt.Fprintf(&buf, "%d . %d . %v . %-6s . %8d .", es.Term, es.Index, es.Type,
humanize.Bytes(uint64(es.Size())), binary.BigEndian.Uint64(es.Data[:8]))
humanize.Bytes(uint64(es.Size())), key)
if es.Type == raftpb.EntryConfChange {
return
}
Expand Down

0 comments on commit bac8fbf

Please sign in to comment.