diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2012-01-29 22:03:51 +0000 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2012-01-29 22:03:51 +0000 |
commit | 9017e316e2ef833d3b49c99ff9e6df70efc9ca44 (patch) | |
tree | a8d5c02739af2a1f1829c6a0c63f82372e925000 | |
parent | 1dd53b5c2e4409e0426c6955bdea820aaa0a50a8 (diff) | |
download | attr-9017e316e2ef833d3b49c99ff9e6df70efc9ca44.tar.gz |
Fixed attributes listing
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | getfattr/getfattr.c | 2 | ||||
-rw-r--r-- | libattr/solaris.c | 24 |
3 files changed, 27 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog index 843a264..9cb65a1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +attr (1:2.4.46-5+dyson2) unstable; urgency=low + + * Fixed attributes listing + + -- Igor Pashev <pashev.igor@gmail.com> Sun, 29 Jan 2012 21:27:28 +0000 + attr (1:2.4.46-5+dyson1) unstable; urgency=low * Ported to Dyson with Solaris xattr support diff --git a/getfattr/getfattr.c b/getfattr/getfattr.c index 692d2d8..dc4dab6 100644 --- a/getfattr/getfattr.c +++ b/getfattr/getfattr.c @@ -306,7 +306,7 @@ int list_attributes(const char *path, int *header_printed) return 1; } else if (length == 0) return 0; - + if (high_water_alloc((void **)&list, &list_size, length)) { perror(progname); had_errors++; diff --git a/libattr/solaris.c b/libattr/solaris.c index 966a977..f5e4426 100644 --- a/libattr/solaris.c +++ b/libattr/solaris.c @@ -91,9 +91,21 @@ __fflistxattr (int xfd, char *list, size_t size) DIR *d; struct dirent *de; size_t l; - +/* + * The fdopendir() function opens a directory stream for the + * directory file descriptor "xfd". The directory file + * descriptor should not be used or closed following a successful + * function call. + * ... + * The closedir() function closes the directory stream referred + * to by the argument "d". Upon return, the value of dirp may + * no longer point to an accessible object of the type DIR. If + * a file descriptor is used to implement type DIR, that file + * descriptor will be closed. + */ d = fdopendir(xfd); if (d == NULL) { + (void) close(xfd); return (-1); } @@ -112,7 +124,11 @@ __fflistxattr (int xfd, char *list, size_t size) /* Define __EXTENSIONS__ for strlcpy() */ /* http://www.gratisoft.us/todd/papers/strlcpy.html */ l = strlcpy(list, de->d_name, size); - if (l >= size) { + + /* if size == 0 we effectively calculate the size of + * a buffer which is sufficiently large to hold the list of names + */ + if ((l >= size) && (size > 0)) { errno = ERANGE; rv = -1; break; @@ -140,7 +156,7 @@ flistxattr (int fd, char *list, size_t size) rv = __fflistxattr(xfd, list, size); - (void) close(xfd); + /* xfd is closed on __fflistxattr() */ return (rv); } @@ -157,7 +173,7 @@ listxattr (const char * path, char *list, size_t size) rv = __fflistxattr(xfd, list, size); - (void) close(xfd); + /* xfd is closed on __fflistxattr() */ return (rv); } |