From: Vladimir 'phcoder' Serbinenko Date: Tue, 8 Nov 2011 18:44:18 +0000 (+0100) Subject: Fix potential problem with calling zfs_to_cpu and cpu_to_be in a row. X-Git-Tag: 2.00~995 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ae17eb83c25cd9b82a8e49a3235168661d8cdbe;p=thirdparty%2Fgrub.git 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. --- diff --git a/ChangeLog b/ChangeLog index 925b798bc..b23f5156d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-11-08 Vladimir Serbinenko + + 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 Fix FreeBSD compilation. diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 14babd29f..13f62b25a 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -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,