lib/deploy: Don't leak fd when checksumming dtbs
authorJonathan Lebon <jonathan@jlebon.com>
Wed, 7 Oct 2020 18:44:25 +0000 (14:44 -0400)
committerJonathan Lebon <jonathan@jlebon.com>
Wed, 7 Oct 2020 18:47:34 +0000 (14:47 -0400)
Likely the root of https://bugzilla.redhat.com/show_bug.cgi?id=1886149.

src/libostree/ostree-sysroot-deploy.c

index 1c4fb5dc8b964e74837c26aeea57605249c941de..7b7ba5e92fad8d987c046ca73f3ed20f34ee2edd 100644 (file)
@@ -272,13 +272,13 @@ checksum_dir_recurse (int          dfd,
         }
       else
         {
-          int fd;
+          glnx_autofd int fd = -1;
 
           if (!ot_openat_ignore_enoent (dfditer.fd, d_name, &fd, error))
             return FALSE;
           if (fd != -1)
             {
-              g_autoptr(GInputStream) in = g_unix_input_stream_new (fd, FALSE);
+              g_autoptr(GInputStream) in = g_unix_input_stream_new (glnx_steal_fd (&fd), TRUE);
               if (!ot_gio_splice_update_checksum (NULL, in, checksum, cancellable, error))
                 return FALSE;
             }