Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions lib/sysxattrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,12 @@ ssize_t sys_llistxattr(const char *path, char *list, size_t size)
* terminator. We need to change this into a series of null-terminted
* strings. Since the size is the same, we can simply transform the
* output in place. */
for (off = 0; off < len; off += keylen + 1) {
keylen = ((unsigned char*)list)[off];
if (off + keylen >= len) {
/* Should be impossible, but bugs happen! */
errno = EINVAL;
return -1;
}
memmove(list+off, list+off+1, keylen);
list[off+keylen] = '\0';
keylen = (unsigned char)list[0];
memmove(list, list+1, len-1);
list[len-1] = '\0';
for (off = keylen; off < (len - 1); off += (keylen + 1)) {
keylen = (unsigned char)list[off];
list[off] = '\0';
}

return len;
Expand Down