[gvfs] fuse: Prevent abortions if modified time is not set



commit 709483017703ef07e725d9ee2de00e1fa8cc4883
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Jan 14 12:57:11 2020 +0100

    fuse: Prevent abortions if modified time is not set
    
    If `G_FILE_ATTRIBUTE_TIME_MODIFIED` is not set for some reason, the
    fuse daemon aborts as it expects that it is always set. Let's use
    g_file_info_has_attribute to prevent the crashes.

 client/gvfsfusedaemon.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 00bd9129..47f4e4c6 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -564,6 +564,7 @@ file_info_get_attribute_as_uint (GFileInfo *file_info, const gchar *attribute)
 
       default:
         uint_result = 0;
+        g_debug ("attribute: %s type: %d\n", attribute, attribute_type);
         g_assert_not_reached ();
         break;
     }
@@ -743,9 +744,12 @@ set_attributes_from_info (GFileInfo *file_info, struct stat *sbuf)
   sbuf->st_uid = daemon_uid;
   sbuf->st_gid = daemon_gid;
 
-  sbuf->st_mtime = file_info_get_attribute_as_uint (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
-  sbuf->st_ctime = sbuf->st_mtime;
-  sbuf->st_atime = sbuf->st_mtime;
+  if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
+    {
+      sbuf->st_mtime = file_info_get_attribute_as_uint (file_info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+      sbuf->st_ctime = sbuf->st_mtime;
+      sbuf->st_atime = sbuf->st_mtime;
+    }
 
   if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_TIME_CHANGED))
     sbuf->st_ctime = file_info_get_attribute_as_uint (file_info, G_FILE_ATTRIBUTE_TIME_CHANGED);


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