[RESTRICT AUTOMERGE] Fix OOB write in noteAtomLogged

It's possible for bad atoms to have negative atom ids. This results in
an OOB write when we note that the atom was logged. This adds a
validation check on the logging.

Also added safetynet logging for negative atoms

Bug: 187957589
Test: POC in bug no longer led to the OOB write & crash
Test: checked event log for safetynet logging
Change-Id: I8a6b094c94309d7b02430fb860891ef814efb426
This commit is contained in:
Tej Singh
2021-05-19 20:12:46 -07:00
parent 0f311f7b28
commit 7f9b0a9fb0

View File

@@ -352,6 +352,10 @@ void StatsdStats::noteAtomLogged(int atomId, int32_t timeSec) {
ALOGW("not interested in atom %d", atomId);
return;
}
if (atomId < 0) {
android_errorWriteLog(0x534e4554, "187957589");
return;
}
mPushedAtomStats[atomId]++;
}