diff options
author | Kenny Root <kroot@google.com> | 2012-05-10 10:21:06 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2012-05-10 11:48:21 -0700 |
commit | 103d53005e7a3c2735f4ac76fa9b795a7e7e39d7 (patch) | |
tree | da5b4a423467f932654ca2db1494bd9e34210f58 /core/tests | |
parent | a25079e6bafcfd77135a852f0e838738d80606ef (diff) | |
download | frameworks_base-103d53005e7a3c2735f4ac76fa9b795a7e7e39d7.zip frameworks_base-103d53005e7a3c2735f4ac76fa9b795a7e7e39d7.tar.gz frameworks_base-103d53005e7a3c2735f4ac76fa9b795a7e7e39d7.tar.bz2 |
Use long instead of int for file offsets
Use long instead of int so we don't run into a 2GB file limit.
Fix possible overflows in offset and length.
Change-Id: Idb3a34f5600f9c2372b9c89256f21757049fa43b
Diffstat (limited to 'core/tests')
-rw-r--r-- | core/tests/coretests/src/android/content/pm/LimitedLengthInputStreamTest.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/core/tests/coretests/src/android/content/pm/LimitedLengthInputStreamTest.java b/core/tests/coretests/src/android/content/pm/LimitedLengthInputStreamTest.java index 0a0152b..1f762fd 100644 --- a/core/tests/coretests/src/android/content/pm/LimitedLengthInputStreamTest.java +++ b/core/tests/coretests/src/android/content/pm/LimitedLengthInputStreamTest.java @@ -66,6 +66,17 @@ public class LimitedLengthInputStreamTest extends AndroidTestCase { } } + @MediumTest + public void testConstructor_OffsetLengthOverflow_Fail() throws Exception { + try { + InputStream is = new LimitedLengthInputStream(mTestStream1, Long.MAX_VALUE - 1, + Long.MAX_VALUE - 1); + fail("Should fail when offset + length is > Long.MAX_VALUE"); + } catch (IOException e) { + // success + } + } + private void checkReadBytesWithOffsetAndLength_WithString1(int offset, int length) throws Exception { byte[] temp = new byte[TEST_STRING1.length]; @@ -182,5 +193,4 @@ public class LimitedLengthInputStreamTest extends AndroidTestCase { public void testSingleByteRead_NonZeroOffset_FullLength_Success() throws Exception { checkSingleByteRead_WithString1(3, TEST_STRING1.length - 3); } - } |