diff options
author | Bob Ippolito <bob@redivi.com> | 2012-02-01 11:28:27 -0800 |
---|---|---|
committer | Bob Ippolito <bob@redivi.com> | 2012-02-01 11:28:27 -0800 |
commit | 5af7a2d7c493b0078b69297ffe79cec5ac76fcad (patch) | |
tree | 6341d73ffb231f6f553e9a4ca32d5eb818332132 | |
parent | 6b6f61eb97e5456bb52edd23acb9ca534f2a1f08 (diff) | |
parent | 312798bd94dd20ce1975599b84ef8ff2285ab1ce (diff) | |
download | xattr-5af7a2d7c493b0078b69297ffe79cec5ac76fcad.tar.gz |
Merge pull request #2 from vineethrp/master
fix couple of solaris issues with xattr
-rw-r--r-- | xattr/_xattr.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/xattr/_xattr.c b/xattr/_xattr.c index ca794ee..1588e8f 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; |