[libglnx: 1/2] xattrs: Fix possible double-free in `get_xattrs_impl`




commit 82e5b7dd568f4bfd8a77b809dd2c067e0a91e892
Author: Jonathan Lebon <jonathan jlebon com>
Date:   Tue Aug 3 16:38:34 2021 -0400

    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>

 glnx-xattrs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/glnx-xattrs.c b/glnx-xattrs.c
index 892d534..785ad0e 100644
--- a/glnx-xattrs.c
+++ b/glnx-xattrs.c
@@ -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");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]