diff options
author | Christopher Ferris <cferris@google.com> | 2020-05-26 10:33:18 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2020-05-28 15:46:51 -0700 |
commit | bff51b88aaf96279c58edb812be0bda2fcaf4967 (patch) | |
tree | fe211c4dcf52f8c83c50cb69a48cc2cf5becd12b /libutils/FileMap_test.cpp | |
parent | 87ee2378de8938cdf561b043c05a3f26323dfd6b (diff) |
Fail explicitly on length overflow.
Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.
Bug: 156997193
Test: Ran unit tests, including new unit test that aborted before.
Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
(cherry picked from commit 68604b9c29b5bd11e2e2dbb848d6b364bf627d21)
Diffstat (limited to 'libutils/FileMap_test.cpp')
-rw-r--r-- | libutils/FileMap_test.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libutils/FileMap_test.cpp b/libutils/FileMap_test.cpp index 9f7ce85ca..fd1c9b0a0 100644 --- a/libutils/FileMap_test.cpp +++ b/libutils/FileMap_test.cpp @@ -52,3 +52,16 @@ TEST(FileMap, large_offset) { ASSERT_EQ(0u, m.getDataLength()); ASSERT_EQ(offset, m.getDataOffset()); } + +TEST(FileMap, offset_overflow) { + // Make sure that an end that overflows SIZE_MAX will not abort. + // See http://b/156997193. + TemporaryFile tf; + ASSERT_TRUE(tf.fd != -1); + + off64_t offset = 200; + size_t length = SIZE_MAX; + + android::FileMap m; + ASSERT_FALSE(m.create("test", tf.fd, offset, length, true)); +} |