simpleperf: check size before reading data for a record.

Currently, we build records from buffer via constructors of Record
classes. And the size check is done after reading data from the buffer.

When the data in the buffer is invalid, it may declare to have very
big size, and cause heap-buffer-overflow reading it. To fix it, add
Parse() function in each Record class to read from the buffer, which
uses an end parameter to check size before reading data from the buffer.

Bug: 205374103
Test: run simpleperf_unit_test

Change-Id: Id838d77320733827c2587bb19915bfb75cccbb64
10 files changed