MCPcopy Create free account
hub / github.com/bodgit/sevenzip / readUint64

Function readUint64

types.go:75–98  ·  view source on GitHub ↗
(r io.ByteReader)

Source from the content-addressed store, hash-verified

73}
74
75func readUint64(r io.ByteReader) (uint64, error) {
76 b, err := r.ReadByte()
77 if err != nil {
78 return 0, fmt.Errorf("readUint64: ReadByte error: %w", err)
79 }
80
81 l := bits.LeadingZeros8(^b)
82
83 var v uint64
84 if l < 7 {
85 v |= uint64(b&((1<<(8-l))-1)) << (8 * l)
86 }
87
88 for i := range l {
89 b, err := r.ReadByte()
90 if err != nil {
91 return 0, fmt.Errorf("readUint64: ReadByte error: %w", err)
92 }
93
94 v |= uint64(b) << (8 * i)
95 }
96
97 return v, nil
98}
99
100// readUint64Bounded is for values that are ultimately used as the length
101// argument of a slice. Fuzzing can generate lengths that will cause a panic.

Callers 7

readUint64BoundedFunction · 0.85
readSizesFunction · 0.85
readPackInfoFunction · 0.85
readFolderFunction · 0.85
readUnpackInfoFunction · 0.85
readSubStreamsInfoFunction · 0.85
readFilesInfoFunction · 0.85

Calls 1

ReadByteMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…