OSDN Git Service

verity: Do not increment data when it is nullptr.
authorMarijnS95 <marijns95@gmail.com>
Mon, 9 Sep 2019 13:50:43 +0000 (15:50 +0200)
committerTianjie Xu <xunchang@google.com>
Mon, 9 Sep 2019 18:18:39 +0000 (18:18 +0000)
commit7920e30eee4c34c571c0260b211fa156de2b3f45
tree03f0467ca07b87dbbcd31416033e67c3a5b1382d
parent96974c3401ce8815ff033e77987a711a2e3c5d48
verity: Do not increment data when it is nullptr.

Address a segfault introduced in
d6dc877032c65768b3c6737156d3142f32cc9984

As soon as leftover_ becomes non-empty, the data pointer is incremented
and will now be an invalid pointer in case it was null previously.
The subsequent check in HashBlocks() will now encounter a non-null data
ptr and pass it to HashBlock(), triggering a segfault.

Test: Manually build and boot an image on which this crashed before.
Test: build_verity_tree_test
Change-Id: I324ff6103c9d35fb290c4e96fb5009ee365a0249
Signed-off-by: MarijnS95 <marijns95@gmail.com>
(cherry picked from commit c82514bd034f214b16d273b10c676dd63a9e603b)
verity/hash_tree_builder.cpp