[New-bugs-announce] [issue18694] getxattr on Linux ZFS native filesystem happily returns partial values

Larry Hastings report at bugs.python.org
Fri Aug 9 06:55:33 CEST 2013

New submission from Larry Hastings:

The getxattr() system call retrieves an "extended attribute" on a file.  When you call it you pass in a buffer and a size.  The expected behavior is, if you pass in a buffer that's too small, the function returns -1 and sets errno to ERANGE.

On a ZFS filesystem on Linux, using the "ZFS On Linux" port:

getxattr() does not behave this way.  Instead, it fills the buffer with the first buffer-size bytes of data (without a zero terminator).

Python's implementation of getxattr() interprets this as success.  Which means that, the way it's implemented, if you call getxattr() to retrieve a value that's > 128 bytes in length, you only get the first 128 bytes.  (Happily, we already have a regression test that finds this!)

Attached is a patch fixing this behavior.  It checks the return value of getxattr() to see if the buffer was filled to 100%.  If so, it retries with a larger buffer.

assignee: larry
components: Library (Lib)
files: larry.setxattr.zfs.patch.1.txt
messages: 194716
nosy: larry
priority: normal
severity: normal
stage: patch review
status: open
title: getxattr on Linux ZFS native filesystem happily returns partial values
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31203/larry.setxattr.zfs.patch.1.txt

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list