mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-12 10:20:08 -04:00
xattr: buffer full check for freebsd
freebsd 10.2: it does not give rc < 0 and errno == ERANGE if the buffer was too small, like linux or mac OS X does. rv == buffer len might be a signal of truncation. rv > buffer len would be even worse not sure if some implementation returns the total length of the data, not just the amount put into the buffer. but as we use the returned length to "truncate" the buffer, we better make sure it is not longer than the buffer. also: freebsd listxattr memoryview len bugfix
This commit is contained in:
parent
4eac66fe2a
commit
7ea052a5e8
1 changed files with 7 additions and 1 deletions
|
|
@ -128,6 +128,12 @@ def _check(rv, path=None, detect_buffer_too_small=False):
|
|||
if isinstance(path, int):
|
||||
path = '<FD %d>' % path
|
||||
raise OSError(e, msg, path)
|
||||
if detect_buffer_too_small and rv >= len(get_buffer()):
|
||||
# freebsd does not error with ERANGE if the buffer is too small,
|
||||
# it just fills the buffer, truncates and returns.
|
||||
# so, we play sure and just assume that result is truncated if
|
||||
# it happens to be a full buffer.
|
||||
raise BufferTooSmallError
|
||||
return rv
|
||||
|
||||
|
||||
|
|
@ -323,7 +329,7 @@ elif sys.platform.startswith('freebsd'): # pragma: freebsd only
|
|||
if n == 0:
|
||||
return []
|
||||
names = []
|
||||
mv = memoryview(buf)
|
||||
mv = memoryview(buf)[:n]
|
||||
while mv:
|
||||
length = mv[0]
|
||||
names.append(os.fsdecode(bytes(mv[1:1 + length])))
|
||||
|
|
|
|||
Loading…
Reference in a new issue