From e33af7fe3782a0c295ef2cd3b588632ecfcc00a4 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Tue, 7 Jun 2022 13:14:04 -0600 Subject: [PATCH] Force-initialize potential padding area. When collapsing our heap-and-stack boundaries, we round up to ensure our padding math is still aligned on the remote side. This rounding can leak a small amount of uninitialized memory, so this change force-initializes any potential padding area. Bug: 213170822 Test: atest libandroidfw_tests Change-Id: Ife6fcd1b74aaabd932a77ea42e0d0ad3a6b9cae6 --- libs/androidfw/CursorWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/androidfw/CursorWindow.cpp b/libs/androidfw/CursorWindow.cpp index 3527eeead1d59..87ae45bedd67e 100644 --- a/libs/androidfw/CursorWindow.cpp +++ b/libs/androidfw/CursorWindow.cpp @@ -227,6 +227,7 @@ status_t CursorWindow::writeToParcel(Parcel* parcel) { if (!dest) goto fail; memcpy(static_cast(dest), static_cast(mData), mAllocOffset); + memset(static_cast(dest) + mAllocOffset, 0, 4); memcpy(static_cast(dest) + compactedSize - slotsSize, static_cast(mData) + mSlotsOffset, slotsSize); }