[glib: 2/4] gio: check the given child name is not an absolute path




commit 3a6e8bc8876e149c36b6b14c6a25a718edb581ed
Author: Marc-André Lureau <marcandre lureau redhat com>
Date:   Fri Oct 22 19:54:11 2021 +0400

    gio: check the given child name is not an absolute path
    
    As this would have undesirable consequence.
    
    Quoting Philip Withnall:
    https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2305#note_1294729:
    
      The documentation never said anything about accepting absolute paths,
      so any code which is relying on that is relying on undocumented
      behaviour. We’re allowed to change that.
    
    Signed-off-by: Marc-André Lureau <marcandre lureau redhat com>

 gio/gfile.c | 1 +
 1 file changed, 1 insertion(+)
---
diff --git a/gio/gfile.c b/gio/gfile.c
index d1eac65fe..08691900f 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -863,6 +863,7 @@ g_file_get_child (GFile      *file,
 {
   g_return_val_if_fail (G_IS_FILE (file), NULL);
   g_return_val_if_fail (name != NULL, NULL);
+  g_return_val_if_fail (!g_path_is_absolute (name), NULL);
 
   return g_file_resolve_relative_path (file, name);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]