bugattr - Bugs: bug #42699, libattr ignores the next xattr if...

 
 

bug #42699: libattr ignores the next xattr if buffer is too small

Submitted by:  Luiz Angelo Daros de Luca <luizluca>
Submitted on:  Mon 07 Jul 2014 07:53:22 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 08 Jul 2014 01:26:28 PM UTC, comment #4:

I confirm the fix. Thanks.

Luiz Angelo Daros de Luca <luizluca>
Mon 07 Jul 2014 10:39:10 PM UTC, comment #3:

Fixed. Thanks for the detailed analysis!

Andreas Gruenbacher <agruen>
Project Administrator
Mon 07 Jul 2014 09:06:25 PM UTC, comment #2:

Thanks for the bug report. It is generally recommended to use getfattr / setfattr instead of attr; attr merely exists for IRIX compatibility. It should nevertheless work though ...

Andreas Gruenbacher <agruen>
Project Administrator
Mon 07 Jul 2014 07:54:35 PM UTC, comment #1:

BTW, I first notice it in version 2.4.43

Luiz Angelo Daros de Luca <luizluca>
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.

Luiz Angelo Daros de Luca <luizluca>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by agruen (Posted a comment)
  • -unavailable- added by luizluca (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 07 Jul 2014 10:39:10 PM UTCagruenStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1