LogAudit.cpp: replace newlines with spaces in audit messages
Some kernels have a bug which causes a newline to show up in audit messages. The embedded newlines cause one message to look like two due to prefix controls. Replace any newlines with spaces. Duplicate spaces are further consolidated in code immediately after this newly added code. Test: create an audit message with a newline, and watch it be cleaned up. Bug: 27878170 Change-Id: Id90c29ab9e10d3be96f51403b0293622d782422a
This commit is contained in:
parent
10a7b9bb8b
commit
2e58867771
|
@ -94,6 +94,13 @@ int LogAudit::logPrint(const char *fmt, ...) {
|
|||
}
|
||||
|
||||
char *cp;
|
||||
// Work around kernels missing
|
||||
// https://github.com/torvalds/linux/commit/b8f89caafeb55fba75b74bea25adc4e4cd91be67
|
||||
// Such kernels improperly add newlines inside audit messages.
|
||||
while ((cp = strchr(str, '\n'))) {
|
||||
*cp = ' ';
|
||||
}
|
||||
|
||||
while ((cp = strstr(str, " "))) {
|
||||
memmove(cp, cp + 1, strlen(cp + 1) + 1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue