On Thursday, 12 March 2020 15:44:46 CET Richard W.M. Jones wrote:
+static char **
+split_attr_names (const char *buf, size_t len)
+{
+ size_t i;
+ DECLARE_STRINGSBUF (ret);
Declare this as CLEANUP_FREE_STRINGSBUF, so there is no need for the
manual calls to free_stringsbuf on failure. take_stringsbuf at the
return is fine, as it will hand over the resources to the caller.
CHROOT_OUT;
if (vlen == -1) {
- reply_with_perror ("getxattr");
+ reply_with_perror ("%s: getxattr", names[i]);
IIRC "what: details" is more common, so "getxattr: %s". (Same for the
other ocurrences.)
goto error;
}
if (vlen > XATTR_SIZE_MAX) {
/* The next call to getxattr will fail anyway, so ... */
- reply_with_error ("extended attribute is too large");
+ reply_with_error ("%s: extended attribute is too large", names[i]);
goto error;
}
- r->guestfs_int_xattr_list_val[j].attrname = strdup (&buf[i]);
- r->guestfs_int_xattr_list_val[j].attrval.attrval_val = malloc (vlen);
- r->guestfs_int_xattr_list_val[j].attrval.attrval_len = vlen;
+ r->guestfs_int_xattr_list_val[i].attrname = strdup (&buf[i]);
names[i]
[you already fixed this, I just amended this message before sending it,
as I started to write it yesterday]
@@ -378,36 +406,36 @@ do_internal_lxattrlist (const char *path, char
*const *names)
entry[m].attrval.attrval_val = NULL;
}
- for (i = 0, j = 0; i < (size_t) len; i += strlen (&buf[i]) + 1, ++j) {
+ for (i = 0; attrnames[i] != NULL; ++i) {
Considering we have nr_attrs at this point, we can use it.
--
Pino Toscano
--
Pino Toscano