libbinder fuzzer: print data from inplace reads
To make sure there are no OOB reads for these two cases.
Bug: 131861045
Test: binder_parcel_fuzzer
Change-Id: Id58fc8e8e72c6fc1c88734794382c1138ffd36f6
diff --git a/libs/binder/fuzzer/util.cpp b/libs/binder/fuzzer/util.cpp
index b3a4ee7..b1213e9 100644
--- a/libs/binder/fuzzer/util.cpp
+++ b/libs/binder/fuzzer/util.cpp
@@ -21,11 +21,17 @@
#include <iomanip>
#include <sstream>
-std::string hexString(const std::vector<uint8_t>& hash) {
+std::string hexString(const void* bytes, size_t len) {
+ if (bytes == nullptr) return "<null>";
+
std::ostringstream s;
s << std::hex << std::setfill('0');
- for (uint8_t i : hash) {
- s << std::setw(2) << static_cast<int>(i);
+ for (size_t i = 0; i < len; i++) {
+ s << std::setw(2) << static_cast<int>(
+ static_cast<const uint8_t*>(bytes)[i]);
}
return s.str();
}
+std::string hexString(const std::vector<uint8_t>& bytes) {
+ return hexString(bytes.data(), bytes.size());
+}