Fixed several bugs found for incidentd
1. Add logging for proto can't be parsed by incident_report
2. Close opened file descriptor of incident report request!
3. Fix invalid syntax of auto-gen section_list.cpp
Bug: 67849582
Test: manually run incident and checks /proc/<its pid>/fd
Change-Id: I38e6ac28de09aca6243ad536ed41d8059e08ba24
diff --git a/cmds/incidentd/src/PrivacyBuffer.cpp b/cmds/incidentd/src/PrivacyBuffer.cpp
index a095afc..d926ea7 100644
--- a/cmds/incidentd/src/PrivacyBuffer.cpp
+++ b/cmds/incidentd/src/PrivacyBuffer.cpp
@@ -20,7 +20,6 @@
#include "io_util.h"
#include <android/util/protobuf.h>
-#include <deque>
using namespace android::util;
diff --git a/cmds/incidentd/src/Reporter.cpp b/cmds/incidentd/src/Reporter.cpp
index 917b70d..34930aa 100644
--- a/cmds/incidentd/src/Reporter.cpp
+++ b/cmds/incidentd/src/Reporter.cpp
@@ -48,6 +48,10 @@
ReportRequest::~ReportRequest()
{
+ if (fd >= 0) {
+ // clean up the opened file descriptor
+ close(fd);
+ }
}
bool
diff --git a/cmds/incidentd/src/report_directory.cpp b/cmds/incidentd/src/report_directory.cpp
index 110902c..65030b3 100644
--- a/cmds/incidentd/src/report_directory.cpp
+++ b/cmds/incidentd/src/report_directory.cpp
@@ -97,7 +97,8 @@
err = BAD_VALUE;
goto done;
}
- if (st.st_uid != AID_SYSTEM || st.st_gid != AID_SYSTEM) {
+ if ((st.st_uid != AID_SYSTEM && st.st_uid != AID_ROOT) ||
+ (st.st_gid != AID_SYSTEM && st.st_gid != AID_ROOT)) {
ALOGE("No incident reports today. Owner is %d and group is %d on report directory %s",
st.st_uid, st.st_gid, directory);
err = BAD_VALUE;