Commit cc4e21f7 authored by Shayan Pooya's avatar Shayan Pooya Committed by Han-Wen Nienhuys

Consult the input.Size in order to differentiate two different opcodes of [get|list]attr

Consulting the output size is incorrect as it does not take into account the
cases where an xattr with an empty value exists.

Moreover, treat listxattr exactly the same as getxattr as the two both
can be used for two different operations.

Add a test for an xattr with an empty value
Signed-off-by: default avatarShayan Pooya <shayan@arista.com>
parent cf21bc21
......@@ -198,12 +198,14 @@ func (r *request) serializeHeader(flatDataSize int) (header []byte) {
dataLength = 0
}
// GETXATTR is two opcodes in one: get xattr size (return
// structured GetXAttrOut, no flat data) and get xattr data
// [GET|LIST]XATTR is two opcodes in one: get/list xattr size (return
// structured GetXAttrOut, no flat data) and get/list xattr data
// (return no structured data, but only flat data)
if r.inHeader.Opcode == _OP_GETXATTR && flatDataSize > 0 {
if r.inHeader.Opcode == _OP_GETXATTR || r.inHeader.Opcode == _OP_LISTXATTR {
if (*GetXAttrIn)(r.inData).Size != 0 {
dataLength = 0
}
}
header = r.outBuf[:sizeOfOutHeader+dataLength]
o := (*OutHeader)(unsafe.Pointer(&header[0]))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment