summaryrefslogtreecommitdiff
path: root/cmds/incident/main.cpp
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2019-05-19 20:51:47 -0700
committerJoe Onorato <joeo@google.com>2019-05-21 13:29:23 -0700
commit3864a348de22e905d22362cfe99b39e76841f49b (patch)
tree631be025cdafe8dcdb1dbc853a82cb47cca03fb4 /cmds/incident/main.cpp
parent5dfe3dfeb83e1da4d6316be11110fe24df40e5a6 (diff)
Fix lookup of incident section by name to not crash.
Bug: 132890298 Test: adb shell incident asdfadfasdfadf doesn't crash Change-Id: I74226960e8e2643df3491cd9dff8e9acc639e24f
Diffstat (limited to 'cmds/incident/main.cpp')
-rw-r--r--cmds/incident/main.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmds/incident/main.cpp b/cmds/incident/main.cpp
index 13e707bc341d..dfb4f994b866 100644
--- a/cmds/incident/main.cpp
+++ b/cmds/incident/main.cpp
@@ -133,11 +133,11 @@ static void section_list(FILE* out) {
static IncidentSection const*
find_section(const char* name)
{
- size_t low = 0;
- size_t high = INCIDENT_SECTION_COUNT - 1;
+ ssize_t low = 0;
+ ssize_t high = INCIDENT_SECTION_COUNT - 1;
while (low <= high) {
- size_t mid = (low + high) >> 1;
+ ssize_t mid = (low + high) / 2;
IncidentSection const* section = INCIDENT_SECTIONS + mid;
int cmp = strcmp(section->name, name);
@@ -304,6 +304,7 @@ main(int argc, char** argv)
} else {
IncidentSection const* ic = find_section(arg);
if (ic == NULL) {
+ ALOGD("Invalid section: %s\n", arg);
fprintf(stderr, "Invalid section: %s\n", arg);
return 1;
}