EGL BlobCache: Add fuzzer for multifile
This fuzzer breaks up the incoming data buffer into
a key and value, then invokes the cache in a few
different ways.
Also includes one small fix to delete a buffer,
discovered while writing the test.
Test: /data/fuzz/arm64/MultifileBlobCache_fuzzer/MultifileBlobCache_fuzzer
Bug: b/261868299
Change-Id: I724584ddb5a92b4b33e371f22f4511cdeb965775
diff --git a/opengl/libs/EGL/MultifileBlobCache.cpp b/opengl/libs/EGL/MultifileBlobCache.cpp
index b5ddd60..7ffdac7 100644
--- a/opengl/libs/EGL/MultifileBlobCache.cpp
+++ b/opengl/libs/EGL/MultifileBlobCache.cpp
@@ -276,11 +276,10 @@
uint8_t* buffer = new uint8_t[fileSize];
- // Write placeholders for magic and CRC until deferred thread complets the write
+ // Write placeholders for magic and CRC until deferred thread completes the write
android::MultifileHeader header = {kMultifileMagic, kCrcPlaceholder, keySize, valueSize};
memcpy(static_cast<void*>(buffer), static_cast<const void*>(&header),
sizeof(android::MultifileHeader));
-
// Write the key and value after the header
memcpy(static_cast<void*>(buffer + sizeof(MultifileHeader)), static_cast<const void*>(key),
keySize);
@@ -301,6 +300,7 @@
// Sending -1 as the fd indicates we don't have an fd for this
if (!addToHotCache(entryHash, -1, buffer, fileSize)) {
ALOGE("SET: Failed to add %u to hot cache", entryHash);
+ delete[] buffer;
return;
}