diff options
author | Jeff Sharkey <jsharkey@android.com> | 2020-10-20 13:19:04 -0600 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2020-10-20 13:19:06 -0600 |
commit | b2bbdaa42f5be34970aae63b37bd0a4272a035db (patch) | |
tree | 6c035426742a28b28bb26247e555adf3b74ec73a /libs/androidfw/tests/CursorWindow_test.cpp | |
parent | c0e3a096904519657bdf808a725e61848132a7f1 (diff) |
Fixed CursorWindow signed math for x86 builds.
All tests for our recent CursorWindow changes have been passing for
ARM 64-bit builds, but they weren't executed against 32-bit x86
builds until after merged.
It's not actually safe to use the "off_t" type, so we need to cast
to "int32_t" when doing checks against possible-negative values,
such as in allocRow().
We also add tests that verify negative rows/columns are identified
as invalid positions, which requires that we check the resulting
pointer against both mSlotsEnd and mSlotsStart.
Bug: 169251528, 171276404, 171275409
Test: atest libandroidfw_tests:CursorWindowTest
Test: atest CtsDatabaseTestCases
Change-Id: Iea5f7546850f691e183fbb6e6d0952cd02b00d0f
Diffstat (limited to 'libs/androidfw/tests/CursorWindow_test.cpp')
-rw-r--r-- | libs/androidfw/tests/CursorWindow_test.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libs/androidfw/tests/CursorWindow_test.cpp b/libs/androidfw/tests/CursorWindow_test.cpp index dfcf76e6edf6..15be80c48192 100644 --- a/libs/androidfw/tests/CursorWindow_test.cpp +++ b/libs/androidfw/tests/CursorWindow_test.cpp @@ -166,6 +166,14 @@ TEST(CursorWindowTest, StoreBounds) { ASSERT_EQ(w->getFieldSlot(0, 3), nullptr); ASSERT_EQ(w->getFieldSlot(3, 0), nullptr); ASSERT_EQ(w->getFieldSlot(3, 3), nullptr); + + // Can't work with invalid indexes + ASSERT_NE(w->putLong(-1, 0, 0xcafe), OK); + ASSERT_NE(w->putLong(0, -1, 0xcafe), OK); + ASSERT_NE(w->putLong(-1, -1, 0xcafe), OK); + ASSERT_EQ(w->getFieldSlot(-1, 0), nullptr); + ASSERT_EQ(w->getFieldSlot(0, -1), nullptr); + ASSERT_EQ(w->getFieldSlot(-1, -1), nullptr); } TEST(CursorWindowTest, Inflate) { |