mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
linux(4): Fix listxattr for the case when the size is 0
If size is specified as zero, these calls return the current size of the list of extended attribute names (and leave list unchanged). Tested by: zirias MFC after: 1 week (cherry picked from commit 18d1c86788f66f42c4e096142f4f8d168f68732c)
This commit is contained in:
parent
bce9c2e340
commit
53b3e15d73
1 changed files with 8 additions and 4 deletions
|
|
@ -173,24 +173,28 @@ listxattr(struct thread *td, struct listxattr_args *args)
|
|||
while (rs > 0) {
|
||||
keylen = (unsigned char)key[0];
|
||||
pairlen = prefixlen + 1 + keylen + 1;
|
||||
if (cnt + pairlen > LINUX_XATTR_LIST_MAX) {
|
||||
cnt += pairlen;
|
||||
if (cnt > LINUX_XATTR_LIST_MAX) {
|
||||
error = E2BIG;
|
||||
break;
|
||||
}
|
||||
if ((args->list != NULL && cnt > args->size) ||
|
||||
/*
|
||||
* If size is specified as zero, return the current size
|
||||
* of the list of extended attribute names.
|
||||
*/
|
||||
if ((args->size > 0 && cnt > args->size) ||
|
||||
pairlen >= sizeof(attrname)) {
|
||||
error = ERANGE;
|
||||
break;
|
||||
}
|
||||
++key;
|
||||
if (args->list != NULL) {
|
||||
if (args->list != NULL && args->size > 0) {
|
||||
sprintf(attrname, "%s.%.*s", prefix, keylen, key);
|
||||
error = copyout(attrname, args->list, pairlen);
|
||||
if (error != 0)
|
||||
break;
|
||||
args->list += pairlen;
|
||||
}
|
||||
cnt += pairlen;
|
||||
key += keylen;
|
||||
rs -= (keylen + 1);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue