From 665ab65e7ea02f2f8f05bfd64e74dcdd792807d5 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Wed, 7 Feb 2024 14:25:41 +0100 Subject: [PATCH 1/2] file_copy_fallback: Check if attributes could be retrieved See #3210 --- gio/gfile.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gio/gfile.c b/gio/gfile.c index 2ceeb3b05..d52262f13 100644 --- a/gio/gfile.c +++ b/gio/gfile.c @@ -3378,10 +3378,24 @@ file_copy_fallback (GFile *source, if (!info) goto out; + if (!g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_TYPE)) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + _("Cannot retrieve attribute %s"), G_FILE_ATTRIBUTE_STANDARD_TYPE); + goto out; + } + /* Maybe copy the symlink? */ if ((flags & G_FILE_COPY_NOFOLLOW_SYMLINKS) && g_file_info_get_file_type (info) == G_FILE_TYPE_SYMBOLIC_LINK) { + if (!g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET)) + { + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + _("Cannot retrieve attribute %s"), G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET); + goto out; + } + target = g_file_info_get_symlink_target (info); if (target) { From 6ee0772146ef3378970e1cfbb358d30438683374 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Thu, 8 Feb 2024 17:06:29 +0100 Subject: [PATCH 2/2] GWinHttpFile: Add support for G_FILE_ATTRIBUTE_STANDARD_TYPE Fixes #3210 --- gio/win32/gwinhttpfile.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gio/win32/gwinhttpfile.c b/gio/win32/gwinhttpfile.c index e73c87658..408c2ade8 100644 --- a/gio/win32/gwinhttpfile.c +++ b/gio/win32/gwinhttpfile.c @@ -537,6 +537,9 @@ g_winhttp_file_query_info (GFile *file, g_free (display_name); } + if (_g_file_attribute_matcher_matches_id (matcher, G_FILE_ATTRIBUTE_ID_STANDARD_TYPE)) + g_file_info_set_file_type (info, G_FILE_TYPE_REGULAR); + content_length = NULL; if (_g_winhttp_query_header (winhttp_file->vfs, request,