Skip to content

Commit ef21956

Browse files
author
dzsekijo
committed
Fix incorrect handling of getxattr for the size=0 case
Report/fix by Facundo Batista, via Sebastien Delafond, cf. https://bugs.launchpad.net/ubuntu/+source/python-fuse/+bug/325860
1 parent ad50197 commit ef21956

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

fuseparts/_fusemodule.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,22 @@ getxattr_func(const char *path, const char *name, char *value, size_t size)
678678
#endif
679679

680680
if(PyString_Check(v)) {
681-
if(PyString_Size(v) > size)
681+
/* size zero can be passed into these calls to return the current size of
682+
* the named extended attribute
683+
*/
684+
if (size == 0) {
685+
ret = PyString_Size(v);
682686
goto OUT_DECREF;
687+
}
688+
689+
/* If the size of the value buffer is too small to hold the result, errno
690+
* is set to ERANGE.
691+
*/
692+
if (PyString_Size(v) > size) {
693+
ret = -ERANGE;
694+
goto OUT_DECREF;
695+
}
696+
683697
memcpy(value, PyString_AsString(v), PyString_Size(v));
684698
ret = PyString_Size(v);
685699
}

0 commit comments

Comments
 (0)