summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuper-User <root@swift.(none)>2011-08-18 00:31:23 -0700
committerSuper-User <root@swift.(none)>2011-08-18 00:31:23 -0700
commit312798bd94dd20ce1975599b84ef8ff2285ab1ce (patch)
tree86b4278f9eceb2f293a510fdfb310b85756f2095
parent60e8bea98c5a3b0ed0e43f5a1043c22741ab5955 (diff)
downloadxattr-312798bd94dd20ce1975599b84ef8ff2285ab1ce.tar.gz
Fix following issues in Solaris port:
coredump when non-existent file specified list() function does not work in solaris.
-rw-r--r--xattr/_xattr.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/xattr/_xattr.c b/xattr/_xattr.c
index 630ec1d..c758cf7 100644
--- a/xattr/_xattr.c
+++ b/xattr/_xattr.c
@@ -387,14 +387,19 @@ static ssize_t xattr_xflistxattr(int xfd, char *namebuf, size_t size, int option
ssize_t nsize = 0;
dirp = fdopendir(xfd);
+ if (dirp == NULL) {
+ return (-1);
+ }
while (entry = readdir(dirp)) {
- esize = strlen(entry->d_name);
- if (nsize + esize + 1 < size) {
- strcat(namebuf + nsize, entry->d_name);
+ if (strcmp(entry->d_name, ".") == 0 ||
+ strcmp(entry->d_name, "..") == 0)
+ continue;
+ esize = strlen(entry->d_name);
+ if (nsize + esize + 1 <= size) {
+ snprintf((char *)(namebuf + nsize), esize + 1,
+ entry->d_name);
+ }
nsize += esize + 1; /* +1 for \0 */
- } else {
- break;
- }
}
closedir(dirp);
return nsize;