Backport "lib/deploy: Don't leak fd when checksumming dtbs"

For Fedora IoT on armhfp:
https://bugzilla.redhat.com/show_bug.cgi?id=1886149
This commit is contained in:
Jonathan Lebon 2020-10-07 15:11:06 -04:00
parent 65d49cb205
commit 0df821ba64
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From b3dc074f5ed6d3a1e40dbc1e3315a518512d3c63 Mon Sep 17 00:00:00 2001
From: Jonathan Lebon <jonathan@jlebon.com>
Date: Wed, 7 Oct 2020 14:44:25 -0400
Subject: [PATCH] lib/deploy: Don't leak fd when checksumming dtbs
Likely the root of https://bugzilla.redhat.com/show_bug.cgi?id=1886149.
---
src/libostree/ostree-sysroot-deploy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libostree/ostree-sysroot-deploy.c b/src/libostree/ostree-sysroot-deploy.c
index 1c4fb5dc..7b7ba5e9 100644
--- a/src/libostree/ostree-sysroot-deploy.c
+++ b/src/libostree/ostree-sysroot-deploy.c
@@ -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;
}
--
2.26.2

View File

@ -8,11 +8,12 @@
Summary: Tool for managing bootable, immutable filesystem trees
Name: ostree
Version: 2020.6
Release: 4%{?dist}
Release: 5%{?dist}
Source0: https://github.com/ostreedev/%{name}/releases/download/v%{version}/libostree-%{version}.tar.xz
License: LGPLv2+
URL: https://ostree.readthedocs.io/en/latest/
Patch0: 0001-deploy-Remove-deployment-bootcsum-assertion.patch
Patch1: 0001-lib-deploy-Don-t-leak-fd-when-checksumming-dtbs.patch
BuildRequires: git
# We always run autogen.sh
@ -168,6 +169,10 @@ find %{buildroot} -name '*.la' -delete
%endif
%changelog
* Wed Oct 07 2020 Jonathan Lebon <jonathan@jlebon.com> - 2020.6-5
- Backport https://github.com/ostreedev/ostree/pull/2211 for
https://bugzilla.redhat.com/show_bug.cgi?id=1886149
* Thu Sep 24 2020 Colin Walters <walters@verbum.org> - 2020.6-4
- Backport https://github.com/ostreedev/ostree/pull/2202