mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-11 01:41:57 -04:00
buzhash chunkers: add len==0 check to avoid buffer over-read
Isn't called by the higher level code with len==0, but adding the check nevertheless for cleaner and less suspicious code.
This commit is contained in:
parent
f94e3dea95
commit
b362b0898e
2 changed files with 4 additions and 0 deletions
|
|
@ -101,6 +101,8 @@ cdef uint32_t _buzhash(const unsigned char* data, size_t len, const uint32_t* h)
|
|||
"""Calculate the buzhash of the given data."""
|
||||
cdef uint32_t i
|
||||
cdef uint32_t sum = 0, imod
|
||||
if len == 0:
|
||||
return 0
|
||||
for i in range(len - 1, 0, -1):
|
||||
imod = i & 0x1f
|
||||
sum ^= BARREL_SHIFT(h[data[0]], imod)
|
||||
|
|
|
|||
|
|
@ -78,6 +78,8 @@ cdef uint64_t _buzhash64(const unsigned char* data, size_t len, const uint64_t*
|
|||
"""Calculate the buzhash of the given data."""
|
||||
cdef uint64_t i
|
||||
cdef uint64_t sum = 0, imod
|
||||
if len == 0:
|
||||
return 0
|
||||
for i in range(len - 1, 0, -1):
|
||||
imod = i & 0x3f
|
||||
sum ^= BARREL_SHIFT64(h[data[0]], imod)
|
||||
|
|
|
|||
Loading…
Reference in a new issue