]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemusecuritymock: Fix bit arithmetic
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Apr 2019 15:17:40 +0000 (17:17 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Jul 2019 06:36:03 +0000 (08:36 +0200)
One of the functions of this mock is that it spoofs chown() and
stat() calls. But it is doing so in a clever way: it stores the
new owner on chown() and reports it on subsequent stat(). This is
done by using a 32bit unsigned integer where one half is used to
store uid the other is for gid. Later, when stat() is called the
integer is fetched and split into halves again. Well, my bit
operation skills are poor and the code I've written does not do
that properly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/qemusecuritymock.c

index d170e5da8fe32a83694d3f90cc955f8845a0b82a..1ca8bd721f9d5b6e346eaf8fb96978784047ccec 100644 (file)
@@ -226,7 +226,7 @@ int virFileRemoveXAttr(const char *path,
                 sb->st_gid = DEFAULT_GID; \
             } else { \
                 /* Known path. Set values passed to chown() earlier */ \
-                sb->st_uid = *val % 16; \
+                sb->st_uid = *val & 0xffff; \
                 sb->st_gid = *val >> 16; \
             } \
 \