Compare commits

...

No commits in common. "c8s" and "c10s" have entirely different histories.
c8s ... c10s

7 changed files with 123 additions and 240 deletions

17
.gitignore vendored
View File

@ -1,2 +1,17 @@
SOURCES/gnome-autoar-0.2.3.tar.xz
/gnome-autoar-0.1.0.tar.xz
/gnome-autoar-0.1.1.tar.xz
/gnome-autoar-0.2.0.tar.xz
/gnome-autoar-0.2.1.tar.xz
/gnome-autoar-0.2.2.tar.xz
/gnome-autoar-0.2.3.tar.xz
/gnome-autoar-0.2.4.tar.xz
/gnome-autoar-0.3.0.tar.xz
/gnome-autoar-0.3.1.tar.xz
/gnome-autoar-0.3.2.tar.xz
/gnome-autoar-0.3.3.tar.xz
/gnome-autoar-0.4.0.tar.xz
/gnome-autoar-0.4.1.tar.xz
/gnome-autoar-0.4.2.tar.xz
/gnome-autoar-0.4.3.tar.xz
/gnome-autoar-0.4.4.tar.xz
/gnome-autoar-0.4.5.tar.xz

View File

@ -1,70 +0,0 @@
From 2c7a42b63913c05326cb66253960517ea0343c6a Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Thu, 25 Feb 2021 14:10:26 +0100
Subject: [PATCH] extractor: Detect conflict also for directories
Current logic doesn't detect conflics when extracting directory. This
is ok, but only for the case when the conflic is caused by directory.
Otherwise, the conflic should be detected and AutoarExtractor should
try to delete the file before creating new directory.
---
gnome-autoar/autoar-extractor.c | 27 ++++++++-------------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index f1f49cf..376c864 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -897,7 +897,6 @@ autoar_extractor_check_file_conflict (GFile *file,
mode_t extracted_filetype)
{
GFileType file_type;
- gboolean conflict = FALSE;
file_type = g_file_query_file_type (file,
G_FILE_QUERY_INFO_NONE,
@@ -907,26 +906,13 @@ autoar_extractor_check_file_conflict (GFile *file,
return FALSE;
}
- switch (extracted_filetype) {
- case AE_IFDIR:
- break;
- case AE_IFREG:
- case AE_IFLNK:
-#if defined HAVE_MKFIFO || defined HAVE_MKNOD
- case AE_IFIFO:
-#endif
-#ifdef HAVE_MKNOD
- case AE_IFSOCK:
- case AE_IFBLK:
- case AE_IFCHR:
-#endif
- conflict = TRUE;
- break;
- default:
- break;
+ /* It is not problem if the directory already exists */
+ if (file_type == G_FILE_TYPE_DIRECTORY &&
+ extracted_filetype == AE_IFDIR) {
+ return FALSE;
}
- return conflict;
+ return TRUE;
}
static void
@@ -1850,6 +1836,9 @@ autoar_extractor_step_extract (AutoarExtractor *self) {
case AUTOAR_CONFLICT_OVERWRITE:
break;
case AUTOAR_CONFLICT_CHANGE_DESTINATION:
+ /* FIXME: If the destination is changed for directory, it should be
+ * changed also for its children...
+ */
g_assert_nonnull (new_extracted_filename);
g_clear_object (&extracted_filename);
extracted_filename = new_extracted_filename;
--
2.31.1

View File

@ -1,126 +0,0 @@
From 3e7b4aca4b0afe9fb1b1160bd26f791d7a636980 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Mon, 1 Mar 2021 17:16:27 +0100
Subject: [PATCH] extractor: Do not allow symlink in parents
Currently, it is still possible that some files are extracted outside of
the destination dir in case of malicious archives. The checks from commit
adb067e6 can be still bypassed in certain cases. See GNOME/file-roller#108
for more details. After some investigation, I am convinced that it would be
best to simply disallow symlinks in parents. For example, `tar` fails to
extract such files with the `ENOTDIR` error. Let's do the same here.
Fixes: https://gitlab.gnome.org/GNOME/gnome-autoar/-/issues/12
---
gnome-autoar/autoar-extractor.c | 59 +++++++++++++++++++++++++--------
1 file changed, 46 insertions(+), 13 deletions(-)
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index ce6e6e9..79a7278 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -892,27 +892,42 @@ autoar_extractor_do_sanitize_pathname (AutoarExtractor *self,
return extracted_filename;
}
-static gboolean
-autoar_extractor_check_file_conflict (GFile *file,
+/* The function checks @file for conflicts with already existing files on the
+ * disk. It also recursively checks parents of @file to be sure it is directory.
+ * It doesn't follow symlinks, so symlinks in parents are also considered as
+ * conflicts even though they point to directory. It returns #GFile object for
+ * the file, which cause the conflict (so @file, or some of its parents). If
+ * there aren't any conflicts, NULL is returned.
+ */
+static GFile *
+autoar_extractor_check_file_conflict (AutoarExtractor *self,
+ GFile *file,
mode_t extracted_filetype)
{
GFileType file_type;
+ g_autoptr (GFile) parent = NULL;
file_type = g_file_query_file_type (file,
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL);
- /* If there is no file with the given name, there will be no conflict */
- if (file_type == G_FILE_TYPE_UNKNOWN) {
- return FALSE;
+
+ /* It is a conflict if the file already exists with an exception for already
+ * existing directories.
+ */
+ if (file_type != G_FILE_TYPE_UNKNOWN &&
+ (file_type != G_FILE_TYPE_DIRECTORY ||
+ extracted_filetype != AE_IFDIR)) {
+ return g_object_ref (file);
}
- /* It is not problem if the directory already exists */
- if (file_type == G_FILE_TYPE_DIRECTORY &&
- extracted_filetype == AE_IFDIR) {
- return FALSE;
+ if ((self->new_prefix && g_file_equal (self->new_prefix, file)) ||
+ (!self->new_prefix && g_file_equal (self->destination_dir, file))) {
+ return NULL;
}
- return TRUE;
+ /* Check also parents for conflict to be sure it is directory. */
+ parent = g_file_get_parent (file);
+ return autoar_extractor_check_file_conflict (self, parent, AE_IFDIR);
}
static void
@@ -1804,7 +1819,7 @@ autoar_extractor_step_extract (AutoarExtractor *self) {
g_autoptr (GFile) extracted_filename = NULL;
g_autoptr (GFile) hardlink_filename = NULL;
AutoarConflictAction action;
- gboolean file_conflict;
+ g_autoptr (GFile) file_conflict = NULL;
if (g_cancellable_is_cancelled (self->cancellable)) {
archive_read_free (a);
@@ -1823,11 +1838,27 @@ autoar_extractor_step_extract (AutoarExtractor *self) {
}
/* Attempt to solve any name conflict before doing any operations */
- file_conflict = autoar_extractor_check_file_conflict (extracted_filename,
+ file_conflict = autoar_extractor_check_file_conflict (self,
+ extracted_filename,
archive_entry_filetype (entry));
while (file_conflict) {
GFile *new_extracted_filename = NULL;
+ /* Do not try to solve any conflicts in parents for now. Especially
+ * symlinks in parents are dangerous as it can easily happen that files
+ * are written outside of the destination. The tar cmd fails to extract
+ * such archives with ENOTDIR. Let's do the same here. This is most
+ * probably malicious, or corrupted archive if the conflict was caused
+ * only by files from the archive...
+ */
+ if (!g_file_equal (file_conflict, extracted_filename)) {
+ self->error = g_error_new (G_IO_ERROR,
+ G_IO_ERROR_NOT_DIRECTORY,
+ "The file is not a directory");
+ archive_read_free (a);
+ return;
+ }
+
action = autoar_extractor_signal_conflict (self,
extracted_filename,
&new_extracted_filename);
@@ -1855,7 +1886,9 @@ autoar_extractor_step_extract (AutoarExtractor *self) {
break;
}
- file_conflict = autoar_extractor_check_file_conflict (extracted_filename,
+ g_clear_object (&file_conflict);
+ file_conflict = autoar_extractor_check_file_conflict (self,
+ extracted_filename,
archive_entry_filetype (entry));
}
--
2.31.1

View File

@ -1,27 +0,0 @@
From c726022a46d780c0cf305788b8126f45704ef462 Mon Sep 17 00:00:00 2001
From: Ondrej Holy <oholy@redhat.com>
Date: Mon, 1 Mar 2021 10:13:17 +0100
Subject: [PATCH] extractor: Do not follow symlinks when detecting conflicts
Currently, symlinks are followed when detecting conflicts. But this
is not desired as the original file caused the conflict, not its target.
---
gnome-autoar/autoar-extractor.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index 376c864..ce6e6e9 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -899,7 +899,7 @@ autoar_extractor_check_file_conflict (GFile *file,
GFileType file_type;
file_type = g_file_query_file_type (file,
- G_FILE_QUERY_INFO_NONE,
+ G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
NULL);
/* If there is no file with the given name, there will be no conflict */
if (file_type == G_FILE_TYPE_UNKNOWN) {
--
2.31.1

View File

@ -1,6 +1,6 @@
--- !Policy
product_versions:
- rhel-8
- rhel-10
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: desktop-qe.desktop-ci.tier1-gating.functional}

View File

@ -1,17 +1,16 @@
Name: gnome-autoar
Version: 0.2.3
Version: 0.4.5
Release: 2%{?dist}
Summary: Archive library
License: LGPLv2+
URL: https://git.gnome.org/browse/gnome-autoar
Source0: https://download.gnome.org/sources/gnome-autoar/0.2/gnome-autoar-%{version}.tar.xz
License: LGPL-2.1-or-later
URL: https://gitlab.gnome.org/GNOME/gnome-autoar
Source0: https://download.gnome.org/sources/%{name}/0.4/%{name}-%{version}.tar.xz
Patch0: extractor-Detect-conflict-also-for-directories.patch
Patch1: extractor-Do-not-follow-symlinks-when-detecting-conf.patch
Patch2: extractor-Do-not-allow-symlink-in-parents.patch
BuildRequires: gcc
BuildRequires: meson
BuildRequires: gtk-doc
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gobject-2.0)
@ -38,21 +37,24 @@ developing applications that use %{name}.
%build
%configure --disable-static
%make_build
%meson -Dvapi=true \
-Dgtk_doc=true \
-Dtests=true \
%{nil}
%meson_build
%install
%make_install
find $RPM_BUILD_ROOT -name '*.la' -delete
%meson_install
%check
make check
%meson_test
%files
%license COPYING
%doc NEWS
%dir %{_libdir}/girepository-1.0
%{_libdir}/girepository-1.0/GnomeAutoar-0.1.typelib
%{_libdir}/girepository-1.0/GnomeAutoarGtk-0.1.typelib
@ -72,11 +74,100 @@ make check
%dir %{_datadir}/vala/vapi
%{_datadir}/vala/vapi/gnome-autoar-0.vapi
%{_datadir}/vala/vapi/gnome-autoar-gtk-0.vapi
%{_datadir}/vala/vapi/gnome-autoar-0.deps
%{_datadir}/vala/vapi/gnome-autoar-gtk-0.deps
%changelog
* Thu Apr 29 2021 Ondrej Holy <oholy@redhat.com> - 0.2.3-2
- CVE-2020-36241, CVE-2021-28650: Do not allow symlink in parents (rhbz#1928701)
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 0.4.5-2
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* Fri Aug 30 2024 David King <amigadave@amigadave.com> - 0.4.5-1
- Update to 0.4.5
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 0.4.4-6
- Bump release for June 2024 mass rebuild
* Fri Feb 09 2024 Ondrej Holy <oholy@redhat.com> - 0.4.4-5
- Migrate to SPDX license
* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Fri Jan 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Wed Jul 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Sat Mar 18 2023 David King <amigadave@amigadave.com> - 0.4.4-1
- Update to 0.4.4
* Thu Jan 19 2023 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Thu Jul 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sun Feb 13 2022 David King <amigadave@amigadave.com> - 0.4.3-1
- Update to 0.4.3
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Fri Jan 07 2022 David King <amigadave@amigadave.com> - 0.4.2-1
- Update to 0.4.2
* Tue Dec 07 2021 Ondrej Holy <oholy@redhat.com> - 0.4.1-2
- Fix extraction of raw format archives
- Run embedded test suite as a part of the build
* Mon Nov 01 2021 Kalev Lember <klember@redhat.com> - 0.4.1-1
- Update to 0.4.1
* Tue Aug 10 2021 Ondrej Holy <oholy@redhat.com> - 0.4.0-1
- Update to 0.4.0
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.3.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Mon Jun 21 2021 Kalev Lember <klember@redhat.com> - 0.3.3-1
- Update to 0.3.3
* Wed May 05 2021 Kalev Lember <klember@redhat.com> - 0.3.2-1
- Update to 0.3.2
* Mon Mar 15 2021 Kalev Lember <klember@redhat.com> - 0.3.1-1
- Update to 0.3.1
* Wed Feb 17 2021 Kalev Lember <klember@redhat.com> - 0.3.0-1
- Update to 0.3.0
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.4-4
- Second attempt - Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Mon Jul 27 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jan 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Tue Jan 07 2020 Kalev Lember <klember@redhat.com> - 0.2.4-1
- Update to 0.2.4
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.3-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Thu Jan 31 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.2.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Sat Mar 03 2018 Kalev Lember <klember@redhat.com> - 0.2.3-1
- Update to 0.2.3

View File

@ -1 +1 @@
SHA512 (gnome-autoar-0.2.3.tar.xz) = f87299817c52e7862a6c1cc950b1c362db8e7465e008d988e70245a203c728a9179400aac8601c399abe361e5a1ac4558b1190641ad3afa7224f883546fae7bc
SHA512 (gnome-autoar-0.4.5.tar.xz) = ba38dfc0ad3c00fd8316d02d1a8e38ce3c743e11032f7c4efff74e7c3f8e8e815a1debe51eae8e2ee653155356d34992f1bc0e35e6cfab82398265fde8648050