unittest: Log to stderr and IPC consistently
vfprintf() has filtering on release builds to avoid accidentally
printing sensitive info, such as pointers. vsnprintf() does not have
this filtering. Because the unittest _tlog() implementation used both,
it was not possible to have consistent formatting and override filtering
with the extra "x" modifier that Trusty libc supports. This change
switches to the filtered version of vsnprintf in the IPC logging so that
it is consistent with stderr (and other code that is designed to work in
release builds). This change should have no effect because all apps that
use the unittest framework should be built in only debug builds anyway.
Test: build.py
Bug: None
Change-Id: I07a48662ad546f3ea273ae03327bf89fcc47123c
diff --git a/lib/unittest/unittest.c b/lib/unittest/unittest.c
index 672ac96..3428032 100644
--- a/lib/unittest/unittest.c
+++ b/lib/unittest/unittest.c
@@ -102,7 +102,8 @@
}
va_start(ap, fmt);
- ret = vsnprintf(buf + 1, sizeof(buf) - 1, fmt, ap);
+ /* use filtered version for consistency with stderr logging */
+ ret = vsnprintf_filtered(buf + 1, sizeof(buf) - 1, fmt, ap);
va_end(ap);
if (ret < 0) {