Pino Toscano
2017-Oct-11 14:37 UTC
[Libguestfs] [PATCH] common/mlutils: fix f_type comparisons
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
Richard W.M. Jones
2017-Oct-11 15:25 UTC
Re: [Libguestfs] [PATCH] common/mlutils: fix f_type comparisons
On Wed, Oct 11, 2017 at 04:37:09PM +0200, Pino Toscano wrote:> 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); > #endifACK. Can you add the commit hash that this fixes to the commit message. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Reasonably Related Threads
- Re: [PATCH v2 2/2] builder: Choose better weights in the planner.
- Re: [PATCH v2 2/2] builder: Choose better weights in the planner.
- linux/magic.h
- [PATCH 0/2] builder: Choose better weights in the planner.
- [PATCH v2 2/2] builder: Choose better weights in the planner.