summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-03-11 14:06:12 -0600
committerMark Salyzyn2016-03-14 11:12:24 -0500
commit2f83d679dd7910cc76d895eb74ab4fabd1e349b2 (patch)
treec7ed6a982933eb737212cda7f42291d51b688582 /liblog/logprint.c
parentb9c078880644b51bc9e6c314eed157f230fce43c (diff)
downloadplatform-system-core-2f83d679dd7910cc76d895eb74ab4fabd1e349b2.tar.gz
platform-system-core-2f83d679dd7910cc76d895eb74ab4fabd1e349b2.tar.xz
platform-system-core-2f83d679dd7910cc76d895eb74ab4fabd1e349b2.zip
liblog: truncate logtags that overflow prefixBuf
Bug: 27585978 Change-Id: If2f45e8787b05b46491a771702746cfc248b9ccd
Diffstat (limited to 'liblog/logprint.c')
-rw-r--r--liblog/logprint.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/liblog/logprint.c b/liblog/logprint.c
index 19a3e2750..02df8ddd6 100644
--- a/liblog/logprint.c
+++ b/liblog/logprint.c
@@ -1429,8 +1429,16 @@ LIBLOG_ABI_PUBLIC char *android_log_formatLogLine (
1429 * possibly causing heap corruption. To avoid this we double check and 1429 * possibly causing heap corruption. To avoid this we double check and
1430 * set the length at the maximum (size minus null byte) 1430 * set the length at the maximum (size minus null byte)
1431 */ 1431 */
1432 prefixLen += MIN(len, sizeof(prefixBuf) - prefixLen); 1432 prefixLen += len;
1433 suffixLen = MIN(suffixLen, sizeof(suffixBuf)); 1433 if (prefixLen >= sizeof(prefixBuf)) {
1434 prefixLen = sizeof(prefixBuf) - 1;
1435 prefixBuf[sizeof(prefixBuf) - 1] = '\0';
1436 }
1437 if (suffixLen >= sizeof(suffixBuf)) {
1438 suffixLen = sizeof(suffixBuf) - 1;
1439 suffixBuf[sizeof(suffixBuf) - 2] = '\n';
1440 suffixBuf[sizeof(suffixBuf) - 1] = '\0';
1441 }
1434 1442
1435 /* the following code is tragically unreadable */ 1443 /* the following code is tragically unreadable */
1436 1444