libfdt: Make get_property_by_offset() less unsafe
Instead of trusting that any non-NULL pointer returned from C is valid
by casting it to a reference, check that it is a valid pointer (properly
aligned for the type), that it points to a property that is fully
contained within the DT slice (this covers NULL validation), and that
the len field of the struct properly matches what libfdt returned (which
we validated).
Test: m pvmfw
Test: atest liblibfdt.integration_test
Change-Id: I72226debc5403f17250fcb0b2d85bbfbba155c98
diff --git a/libs/libfdt/Android.bp b/libs/libfdt/Android.bp
index ba9e971..b5f7471 100644
--- a/libs/libfdt/Android.bp
+++ b/libs/libfdt/Android.bp
@@ -39,6 +39,7 @@
rustlibs: [
"libcstr",
"liblibfdt_bindgen",
+ "libmemoffset_nostd",
"libzerocopy_nostd",
],
whole_static_libs: [