1 |
From cd081619d1597d07ce77fec4474e44dae9132f52 Mon Sep 17 00:00:00 2001 |
2 |
From: Aleksandar Dezelin <dezelin@gmail.com> |
3 |
Date: Fri, 23 Dec 2022 15:58:26 +0000 |
4 |
Subject: [PATCH] Fix crash when copying an invalid file |
5 |
|
6 |
--- |
7 |
src/nautilus-dbus-manager.c | 5 +++++ |
8 |
src/nautilus-file-operations.c | 6 ++++++ |
9 |
2 files changed, 11 insertions(+) |
10 |
|
11 |
--- a/src/nautilus-dbus-manager.c |
12 |
+++ b/src/nautilus-dbus-manager.c |
13 |
@@ -187,6 +187,11 @@ handle_create_folder (NautilusDBusFileOp |
14 |
file = g_file_new_for_uri (uri); |
15 |
basename = g_file_get_basename (file); |
16 |
parent_file = g_file_get_parent (file); |
17 |
+ if (parent_file == NULL || basename == NULL) |
18 |
+ { |
19 |
+ g_dbus_method_invocation_return_error (invocation, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "Invalid uri: %s", uri); |
20 |
+ return TRUE; |
21 |
+ } |
22 |
parent_file_uri = g_file_get_uri (parent_file); |
23 |
|
24 |
handle_create_folder_internal (parent_file_uri, basename, NULL); |
25 |
--- a/src/nautilus-file-operations.c |
26 |
+++ b/src/nautilus-file-operations.c |
27 |
@@ -1022,6 +1022,11 @@ get_basename (GFile *file) |
28 |
if (name == NULL) |
29 |
{ |
30 |
basename = g_file_get_basename (file); |
31 |
+ if (basename == NULL) |
32 |
+ { |
33 |
+ return g_strdup (_("unknown")); |
34 |
+ } |
35 |
+ |
36 |
if (g_utf8_validate (basename, -1, NULL)) |
37 |
{ |
38 |
name = basename; |
39 |
@@ -4385,6 +4390,7 @@ get_unique_target_file (GFile *src, |
40 |
if (dest == NULL) |
41 |
{ |
42 |
basename = g_file_get_basename (src); |
43 |
+ g_assert (basename == NULL); |
44 |
|
45 |
if (g_utf8_validate (basename, -1, NULL)) |
46 |
{ |