summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorMichael Terry <mike@mterry.name>2017-08-20 00:06:47 -0400
committerOndrej Holy <oholy@redhat.com>2017-08-21 16:54:14 +0200
commitcdaa10cef32ed935a783b2700675be0af3c9542e (patch)
tree290fb2188b24b42a9fbf6dcec299a915679323d4 /client
parentdd2b1ff8cfb28434f35b0657b9becd059ecf3c08 (diff)
downloadgvfs-cdaa10cef32ed935a783b2700675be0af3c9542e.tar.gz
daemon: Avoid overflowing when querying for filesystem info
Filesystem sizes can be large and in danger of overflowing. Guard against that possibility in the dav and fuse FS query code. https://bugzilla.gnome.org/show_bug.cgi?id=786177
Diffstat (limited to 'client')
-rw-r--r--client/gvfsfusedaemon.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 5a7767c2..ff5641ae 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -645,7 +645,10 @@ vfs_statfs (const gchar *path, struct statvfs *stbuf)
if (file_info)
{
if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE))
- stbuf->f_blocks = (g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE) + 4096 - 1) / 4096;
+ {
+ guint64 size = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE);
+ stbuf->f_blocks = (size > 0) ? ((size - 1) / 4096 + 1) : 0;
+ }
if (g_file_info_has_attribute (file_info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE))
stbuf->f_bfree = stbuf->f_bavail = g_file_info_get_attribute_uint64 (file_info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE) / 4096;