aboutsummaryrefslogtreecommitdiff
path: root/mkfs
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-18 12:38:32 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-11-18 12:39:43 +0100
commit18bf3a0effeb1d4bd5f544f442b03b6265addbd2 (patch)
treeb510d0affb6240685be3a25380eca6cc72181cc2 /mkfs
parentf2333bdf01e0894a412d1ab5d395687aa189eef1 (diff)
Fix: do not follow symlinks when scanning xattrs from a directory
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r--mkfs/dirscan.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/mkfs/dirscan.c b/mkfs/dirscan.c
index 334957a..b380d73 100644
--- a/mkfs/dirscan.c
+++ b/mkfs/dirscan.c
@@ -51,9 +51,9 @@ static int xattr_from_path(sqfs_xattr_writer_t *xwr, const char *path)
ssize_t buflen, vallen, keylen;
int ret;
- buflen = listxattr(path, NULL, 0);
+ buflen = llistxattr(path, NULL, 0);
if (buflen < 0) {
- perror("listxattr");
+ fprintf(stderr, "llistxattr %s: %s", path, strerror(errno));
return -1;
}
@@ -66,17 +66,20 @@ static int xattr_from_path(sqfs_xattr_writer_t *xwr, const char *path)
return -1;
}
- buflen = listxattr(path, buffer, buflen);
+ buflen = llistxattr(path, buffer, buflen);
if (buflen == -1) {
- perror("listxattr");
+ fprintf(stderr, "llistxattr %s: %s", path, strerror(errno));
goto fail;
}
key = buffer;
while (buflen > 0) {
- vallen = getxattr(path, key, NULL, 0);
- if (vallen == -1)
+ vallen = lgetxattr(path, key, NULL, 0);
+ if (vallen == -1) {
+ fprintf(stderr, "lgetxattr %s: %s",
+ path, strerror(errno));
goto fail;
+ }
if (vallen > 0) {
value = calloc(1, vallen);
@@ -85,9 +88,9 @@ static int xattr_from_path(sqfs_xattr_writer_t *xwr, const char *path)
goto fail;
}
- vallen = getxattr(path, key, value, vallen);
+ vallen = lgetxattr(path, key, value, vallen);
if (vallen == -1) {
- fprintf(stderr, "%s: getxattr: %s\n",
+ fprintf(stderr, "lgetxattr %s: %s\n",
path, strerror(errno));
goto fail;
}