vboot: Fix potential alignment issue reading FWMP
authorRandall Spangler <rspangler@chromium.org>
Thu, 21 Jul 2016 22:33:31 +0000 (15:33 -0700)
committerchrome-bot <chrome-bot@chromium.org>
Fri, 22 Jul 2016 20:35:56 +0000 (13:35 -0700)
commitb3a625f8fef1768d78eab4cfaaea270cb3fbd0c3
treed472ca14b51562dc3522d844cbe50e742928e493
parentbea3f7979a4c3088da74accd1b68830214e0934d
vboot: Fix potential alignment issue reading FWMP

RollbackFwmpRead() assumed that a uint8[] array on the stack would be
aligned sufficiently for typecasting to struct RollbackSpaceFwmp and
accessing its members.

This was true on x86 (where unaligned accesses work fine) and probably
harmless on other platforms (since RollbackSpaceFwmp is
__attribute__(packed).  But it's cleaner to switch to using a union of
the buffer and struct, since that will provide the proper alignment.

BUG=chromium:601492
BRANCH=baytrail and newer platforms
TEST=make -j runtests

Change-Id: I97077923ab5809c68510cbd382541bf2827aba6b
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/362087
Commit-Ready: Dan Shi <dshi@google.com>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
firmware/lib/rollback_index.c