[Libguestfs] [PATCH] common/mlutils: fix f_type comparisons

Pino Toscano ptoscano at redhat.com
Wed Oct 11 14:37:09 UTC 2017


statfs::f_type is usually a signed type, so cast it to unsigned to check
its value against magic values of filesystems.
---
 common/mlutils/unix_utils-c.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/mlutils/unix_utils-c.c b/common/mlutils/unix_utils-c.c
index f8c4f8abe..2afdc9e5f 100644
--- a/common/mlutils/unix_utils-c.c
+++ b/common/mlutils/unix_utils-c.c
@@ -357,9 +357,9 @@ guestfs_int_mllib_statvfs_is_network_filesystem (value pathv)
 #define SMB_SUPER_MAGIC 0x517b
 #endif
 
-  return Val_bool (buf.f_type == CIFS_MAGIC_NUMBER ||
-                   buf.f_type == NFS_SUPER_MAGIC ||
-                   buf.f_type == SMB_SUPER_MAGIC);
+  return Val_bool ((unsigned int) buf.f_type == CIFS_MAGIC_NUMBER ||
+                   (unsigned int) buf.f_type == NFS_SUPER_MAGIC ||
+                   (unsigned int) buf.f_type == SMB_SUPER_MAGIC);
 #else
   return Val_bool (0);
 #endif
-- 
2.13.6




More information about the Libguestfs mailing list