xattrs: Fix possible double-free in get_xattrs_impl

When we free `xattr_name`, we need to transfer ownership away to avoid
potential for a double-free if we hit `ENOTSUP` on the next iteration.

Reported-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
Jonathan Lebon
2021-08-03 16:38:34 -04:00
parent b7a2d4dc59
commit 82e5b7dd56

View File

@@ -181,7 +181,7 @@ get_xattrs_impl (const char *path,
{
if (errno == ERANGE)
{
g_free (xattr_names);
g_free (g_steal_pointer (&xattr_names));
goto again;
}
glnx_set_prefix_error_from_errno (error, "%s", "llistxattr");