[gvfs] daemon: Avoid overflowing when querying for filesystem info
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] daemon: Avoid overflowing when querying for filesystem info
- Date: Mon, 21 Aug 2017 14:55:56 +0000 (UTC)
commit cdaa10cef32ed935a783b2700675be0af3c9542e
Author: Michael Terry <mike mterry name>
Date: Sun Aug 20 00:06:47 2017 -0400
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
client/gvfsfusedaemon.c | 5 ++++-
daemon/gvfsbackenddav.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 5a7767c..ff5641a 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;
diff --git a/daemon/gvfsbackenddav.c b/daemon/gvfsbackenddav.c
index e8a3903..7ff7b91 100644
--- a/daemon/gvfsbackenddav.c
+++ b/daemon/gvfsbackenddav.c
@@ -1202,7 +1202,7 @@ ms_response_to_fs_info (MsResponse *response,
g_file_info_set_attribute_uint64 (info,
G_FILE_ATTRIBUTE_FILESYSTEM_FREE,
bytes_avail);
- if (have_bytes_used)
+ if (have_bytes_used && G_MAXUINT64 - bytes_avail >= bytes_used)
g_file_info_set_attribute_uint64 (info,
G_FILE_ATTRIBUTE_FILESYSTEM_SIZE,
bytes_avail + bytes_used);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]