Commit Graph

3 Commits

Author SHA1 Message Date
Michael Wachenschwanz
240896281b Throw ProtoParseException for incomplete values
Reading a corrupted stream/file could cause an infinite loop while
reading values. Throw an exception if unexpectedly reached the end of
the stream.

Bug: 150192344
Test: atest ProtoInputStreamTests
Change-Id: Ie660545152ba821be0c371dd1e3bf7235372bc6d
2020-02-27 17:44:14 -08:00
Kweku Adams
6acbca3a9a Rename ProtoInputStream.isNextField to nextField.
ProtoInputStream.isNextField() skips over the current field to read the
next tag. This side effect means that calling isNextField prevents the
caller from reading the field it was just on. The "is" prefix makes it
easy to assume that the method has no side effects. Renaming to
nextField(long) with a parameter should help make it clear that the call
is as dangerous as calling nextField().

Fixes: 137294060
Test: atest android.app.usage.UsageStatsTest
Test: atest android.app.usage.cts.UsageStatsTest
Test: atest com.android.server.usage.UsageStatsDatabaseTest
Test: atest ProtoInputStreamTests
Change-Id: Ibfb8ef741f27a211f076dc0b715b64acbfc0696a
2019-07-12 17:10:39 -07:00
Michael Wachenschwanz
d3538564e5 Remove Test Api annotation from ProtoInputStream
Also move cts tests to unit tests

Test: atest ProtoInputStreamTests
Fixes: 115635242
Change-Id: I9aff1227328aad6ec2bec3471f73ae90293a028d
2019-04-04 20:23:29 +00:00