summaryrefslogtreecommitdiffstats
path: root/logd/LogAudit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'logd/LogAudit.cpp')
-rw-r--r--logd/LogAudit.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/logd/LogAudit.cpp b/logd/LogAudit.cpp
index 1056ae4..add0f0e 100644
--- a/logd/LogAudit.cpp
+++ b/logd/LogAudit.cpp
@@ -16,6 +16,7 @@
#include <ctype.h>
#include <errno.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/klog.h>
@@ -39,6 +40,10 @@ bool LogAudit::onDataAvailable(SocketClient *cli) {
struct audit_message rep;
+ rep.nlh.nlmsg_type = 0;
+ rep.nlh.nlmsg_len = 0;
+ rep.data[0] = '\0';
+
if (audit_get_reply(cli->getSocket(), &rep, GET_REPLY_BLOCKING, 0) < 0) {
SLOGE("Failed on audit_get_reply with error: %s", strerror(errno));
return false;
@@ -146,11 +151,8 @@ int LogAudit::logPrint(const char *fmt, ...) {
strcpy(newstr + 1 + l, str);
free(str);
- unsigned short len = n; // cap to internal maximum
- if (len != n) {
- len = -1;
- }
- logbuf->log(AUDIT_LOG_ID, now, uid, pid, tid, newstr, len);
+ logbuf->log(AUDIT_LOG_ID, now, uid, pid, tid, newstr,
+ (n <= USHRT_MAX) ? (unsigned short) n : USHRT_MAX);
reader->notifyNewLog();
free(newstr);