]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix potential problem with calling zfs_to_cpu and cpu_to_be in a row.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 8 Nov 2011 18:44:18 +0000 (19:44 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 8 Nov 2011 18:44:18 +0000 (19:44 +0100)
* grub-core/fs/zfs/zfscrypt.c (grub_zfs_decrypt_real): Use explicit
byteswap when needed.

ChangeLog
grub-core/fs/zfs/zfscrypt.c

index 925b798bc5ddd23c42df49c76ed25fb55628b17f..b23f5156df200af2ba33ace26f810c27986f1809 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-11-08  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Fix potential problem with calling zfs_to_cpu and cpu_to_be in a row.
+
+       * grub-core/fs/zfs/zfscrypt.c (grub_zfs_decrypt_real): Use explicit
+       byteswap when needed.
+
 2011-11-08  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Fix FreeBSD compilation.
index 14babd29fa2a538c0bfa794eb94d32cfb70ed03b..13f62b25a1eecca92d71af167449df4fcf2a13a7 100644 (file)
@@ -277,8 +277,9 @@ grub_zfs_decrypt_real (grub_crypto_cipher_handle_t cipher,
   grub_err_t err;
       
   grub_memcpy (sw, nonce, 16);
-  for (i = 0; i < 4; i++)
-    sw[i] = grub_cpu_to_be32 (grub_zfs_to_cpu32 (sw[i], endian));
+  if (endian != GRUB_ZFS_BIG_ENDIAN)
+    for (i = 0; i < 4; i++)
+      sw[i] = grub_swap_bytes32 (sw[i]);
 
   if (!cipher)
     return grub_error (GRUB_ERR_ACCESS_DENIED,