/*
Bacula® - The Network Backup Solution
- Copyright (C) 2008-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2008-2010 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
*/
bp = xattr_list;
while ((bp - xattr_list) + 1 < xattr_list_len) {
+ int name_len;
skip_xattr = false;
/*
}
}
- if (skip_xattr) {
+ name_len = strlen(bp);
+ if (skip_xattr || name_len == 0) {
bp = strchr(bp, '\0') + 1;
continue;
}
/*
* Allocate space for storing the name.
*/
- current_xattr->name_length = strlen(bp);
+ current_xattr->name_length = name_len;
current_xattr->name = (char *)malloc(current_xattr->name_length);
memcpy((caddr_t)current_xattr->name, (caddr_t)bp, current_xattr->name_length);
* Print the current name into the buffer as its not null terminated we need to
* use the length encoded in the string for copying only the needed bytes.
*/
- cnt = MIN((int)(sizeof(current_attrname) - 1), xattr_list[index]);
+ cnt = xattr_list[index];
+ if (cnt > ((int)sizeof(current_attrname) - 1)) {
+ cnt = ((int)sizeof(current_attrname) - 1);
+ }
strncpy(current_attrname, xattr_list + (index + 1), cnt);
current_attrname[cnt] = '\0';