Commit cf3a86f
Avoid NPE in CriticalEventLog.saveLogToFileNow()
A malformed event can cause an NPE in
CriticalEventLog.saveLogToFileNow() when
CriticalEventLogStorageProto.toByteArray() calls
computeSerializedSize() on an event with null fields. This leads to a crash system_server and will force a device reboot.
Move the toByteArray() call into the try-with-resources block
and broaden the catch from IOException to Exception so that
any exception during serialization or writing is caught and
logged rather than crashing the system_server.
Bug: None
Test: atest CriticalEventLogTest
Change-Id: I57190fc3245f9f03950f0cf7597fa3d4d2a5b5501 parent bdb5f7d commit cf3a86f
2 files changed
Lines changed: 18 additions & 2 deletions
File tree
- services
- core/java/com/android/server/criticalevents
- tests/servicestests/src/com/android/server/criticalevents
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
401 | 400 | | |
| 401 | + | |
402 | 402 | | |
403 | | - | |
| 403 | + | |
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
576 | 576 | | |
577 | 577 | | |
578 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
579 | 595 | | |
580 | 596 | | |
581 | 597 | | |
| |||
0 commit comments