Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d041aa4d authored by Steven Moreland's avatar Steven Moreland Committed by Android (Google) Code Review
Browse files

Merge changes I0f4a50be,Ib613b7ab

* changes:
  binder_parcel_fuzzer: faster string creation
  binder_parcel_fuzzer: dump more info
parents f075c1fe 2884dd8b
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -36,12 +36,17 @@ void doFuzz(

    for (size_t i = 0; i < instructions.size() - 1; i += 2) {
        uint8_t a = instructions[i];
        uint8_t readIdx = a % reads.size();

        uint8_t b = instructions[i + 1];

        FUZZ_LOG() << "size: " << p.dataSize() << " avail: " << p.dataAvail()
                   << " pos: " << p.dataPosition() << " cap: " << p.dataCapacity();
        FUZZ_LOG() << "Instruction: " << (i / 2) + 1 << "/" << instructions.size() / 2
                   << " cmd: " << static_cast<size_t>(a) << " (" << static_cast<size_t>(readIdx)
                   << ") arg: " << static_cast<size_t>(b) << " size: " << p.dataSize()
                   << " avail: " << p.dataAvail() << " pos: " << p.dataPosition()
                   << " cap: " << p.dataCapacity();

        reads[a % reads.size()](p, b);
        reads[readIdx](p, b);
    }
}

+9 −5
Original line number Diff line number Diff line
@@ -24,13 +24,17 @@
std::string hexString(const void* bytes, size_t len) {
    if (bytes == nullptr) return "<null>";

    std::ostringstream s;
    s << std::hex << std::setfill('0');
    const uint8_t* bytes8 = static_cast<const uint8_t*>(bytes);
    char chars[] = "0123456789abcdef";
    std::string result;
    result.resize(len * 2);

    for (size_t i = 0; i < len; i++) {
        s << std::setw(2) << static_cast<int>(
            static_cast<const uint8_t*>(bytes)[i]);
        result[2 * i] = chars[bytes8[i] >> 4];
        result[2 * i + 1] = chars[bytes8[i] & 0xf];
    }
    return s.str();

    return result;
}
std::string hexString(const std::vector<uint8_t>& bytes) {
    return hexString(bytes.data(), bytes.size());