Skip to content

Commit

Permalink
logd: klogd deal with nuls in dmesg
Browse files Browse the repository at this point in the history
Switch to using string and length in all transactions, treating
trailing nuls the same as spaces.

ToDo: change dumpstate (bugreport) to use logcat -b printable _regardless_

Bug: 23517551
Change-Id: I42162365e6bf8ed79d356e7b689a673902116fdb
  • Loading branch information
Mark Salyzyn authored and Steve Kondik committed Nov 1, 2015
1 parent f3337cb commit 0d139dd
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 94 deletions.
6 changes: 3 additions & 3 deletions logd/LogAudit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,17 @@ int LogAudit::logPrint(const char *fmt, ...) {
return rc;
}

int LogAudit::log(char *buf) {
int LogAudit::log(char *buf, size_t len) {
char *audit = strstr(buf, " audit(");
if (!audit) {
if (!audit || (audit >= &buf[len])) {
return 0;
}

*audit = '\0';

int rc;
char *type = strstr(buf, "type=");
if (type) {
if (type && (type < &buf[len])) {
rc = logPrint("%s %s", type, audit + 1);
} else {
rc = logPrint("%s", audit + 1);
Expand Down
2 changes: 1 addition & 1 deletion logd/LogAudit.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class LogAudit : public SocketListener {

public:
LogAudit(LogBuffer *buf, LogReader *reader, int fdDmesg);
int log(char *buf);
int log(char *buf, size_t len);

protected:
virtual bool onDataAvailable(SocketClient *cli);
Expand Down
Loading

0 comments on commit 0d139dd

Please sign in to comment.