[PATCH 2/2] storage: Need to properly read the crypt offset value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit id 'a48c7141' altered how to determine if a volume was encrypted
by adding a peek at an offset into the file at a specific buffer location.
Unfortunately, all that was compared was the first "char" of the buffer
against the expect "int" value.

Restore the virReadBufInt32BE to get the complete field in order to
compare against the expected value from the qcow2EncryptionInfo or
qcow1EncryptionInfo "modeValue" field.

This restores the capability to create a volume with encryption, then
refresh the pool, and still find the encryption for the volume.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/virstoragefile.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 41827f0..272db67 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -888,7 +888,7 @@ virStorageFileHasEncryptionFormat(const struct FileEncryptionInfo *info,
                                   size_t len)
 {
     if (!info->magic && info->modeOffset == -1)
-        return 0; /* Shouldn't happen - expect at least one */
+        return false; /* Shouldn't happen - expect at least one */
 
     if (info->magic) {
         if (!virStorageFileMatchesMagic(info->magicOffset,
@@ -906,10 +906,13 @@ virStorageFileHasEncryptionFormat(const struct FileEncryptionInfo *info,
 
         return true;
     } else if (info->modeOffset != -1) {
+        int crypt_format;
+
         if (info->modeOffset >= len)
             return false;
 
-        if (buf[info->modeOffset] != info->modeValue)
+        crypt_format = virReadBufInt32BE(buf + info->modeOffset);
+        if (crypt_format != info->modeValue)
             return false;
 
         return true;
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]