Mon 07 Jul 2014 07:53:22 PM UTC, original submission:
Hello,
attr_list and attr_listf writes the xattr size and name to a arg buffer. If this buffer is too small (attrlist.al_more==1) to fit all xattrs, the program should call it again.
While testing a program that uses libattr, I noticed that when the buffer for attr_listf (and probably attr_list) is too small for all xattr, the next attr_listf call misses the next attribute. It is reproducible with attr too.
$ cd attr-git
$ ./autogen.sh
$ ./configure
$ make attr
$ touch test
$ cat >test.attr
# file: test
user.sha1="33e01b9ee571ecd5702e525e6d631b1aec3d1db8"
user.teste="2014-07-04T16:03:05-03:00"
user.teste2="2014-07-07T16:14:48-03:00"
$ setfattr --restore=test.attr
$ ./attr -l test
Attribute "sha1" has a 40 byte value for test
Attribute "teste" has a 25 byte value for test
Attribute "teste2" has a 25 byte value for test
# All attributes are ok
# Reducing buffer to 40 bytes
$ sed -r -iold -e 's/#define[[:blank:]]+BUFSIZE.*/#define BUFSIZE 40/' tools/attr.c
$ make attr
$ ./attr -l test
Attribute "sha1" has a 40 byte value for test
Attribute "teste2" has a 25 byte value for test
# Fist call got sha1. Next got only teste2
# Now I increase buffer to 60 in order to fit sha1 and teste into the first buffer
$ sed -r -iold -e 's/#define[[:blank:]]+BUFSIZE.*/#define BUFSIZE 60/' tools/attr.c
$ make attr
$ ./attr -l test
Attribute "sha1" has a 40 byte value for test
Attribute "teste" has a 25 byte value for test
# Now it missed the last one.
|