bugattr - Bugs: bug #37027, attr_multi will never perform a...

 
 

bug #37027: attr_multi will never perform a remove operation with ATTR_OP_REMOVE

Submitter:  None
Submitted:  Sat 04 Aug 2012 02:47:54 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 15 Sep 2017 01:54:22 PM UTC, comment #1: 

Fixed in the following commit:

commit feaf46e9a95cec83c6300649fabd3be9ad508e20
Author: Andreas Gruenbacher <agruen@linbit.com>
Date:   Mon Aug 6 13:31:20 2012 +0200

    Fix ATTR_OP_REMOVE operation in attr_multi()
   
    The ATTR_OP_GET, ATTR_OP_SET, and ATTR_OP_REMOVE constants are not single bit
    values, so use comparisons instead of bit tests to check which of those
    operations to perform.  (Up to now, ATTR_OP_REMOVE was wrongly detected as
    ATTR_OP_GET.)

Andreas Gruenbacher <agruen>
Group administrator
Sat 04 Aug 2012 02:47:54 PM UTC, original submission:  

I've been trying to remove attributes by calling attr_multi, but according to strace the syscall getxattr is being called instead of removexattr.

Looking at the relevant files in package version 2.4.46 we have in include/attributes.h:

/*

  • Valid values of am_opcode.

 */
#define ATTR_OP_GET     1       /* return the indicated attr's value */
#define ATTR_OP_SET     2       /* set/create the indicated attr/value pair */
#define ATTR_OP_REMOVE  3       /* remove the indicated attr */

and in libattr/libattr.c:

static int
attr_single(const char *path, attr_multiop_t *op, int flags)
{
        int r = -1;

        errno = -EINVAL;
        flags |= op->am_flags;
        if (op->am_opcode & ATTR_OP_GET)
                r = attr_get(path, op->am_attrname, op->am_attrvalue,
                                &op->am_length, flags);
        else if (op->am_opcode & ATTR_OP_SET)
                r = attr_set(path, op->am_attrname, op->am_attrvalue,
                                op->am_length, flags);
        else if (op->am_opcode & ATTR_OP_REMOVE)
                r = attr_remove(path, op->am_attrname, flags);
        return r;
}


since ATTR_OP_GET & ATTR_OP_REMOVE == 1, the dispatching code above will never call the attr_remove() function. The code needs to either
- change the order of comparisons
- switch to comparing with == instead of bitbanging
- redefining ATTR_OP_REMOVE to 4 instead of 3.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by agruen (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-09-15 agruen StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code