summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Öhrström <tobias.ohrstrom@volvocars.com>2020-11-17 10:54:37 +0100
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2020-11-19 16:23:07 +0900
commit723344e43485c105fe79d21e2ba4c0dcd3dd0ca7 (patch)
treec1aded582f4dbf28d1ea394c6cd019dc8b7b1aa0
parent5f852ae115a33ce9166fb73791dc062fc0ac95f5 (diff)
downloadDLT-daemon-723344e43485c105fe79d21e2ba4c0dcd3dd0ca7.tar.gz
Add message length check
Adds message length check to android-logd-converter handle malformed message. Signed-off-by: Tobias Öhrström <tobias.ohrstrom@volvocars.com>
-rw-r--r--src/android/dlt-logd-converter.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/android/dlt-logd-converter.cpp b/src/android/dlt-logd-converter.cpp
index 250d562..77e37a8 100644
--- a/src/android/dlt-logd-converter.cpp
+++ b/src/android/dlt-logd-converter.cpp
@@ -167,9 +167,15 @@ static int logd_parser_loop(struct logger_list *logger_list)
DltLogLevelType log_level;
log_level = get_log_level_from_log_msg(&log_msg);
- /* Look into system/core/liblog/logprint.c for buffer format */
- auto tag = log_msg.msg()+1;
- auto message = tag+strlen(tag)+1;
+ /* Look into system/core/liblog/logprint.c for buffer format.
+ "<priority:1><tag:N>\0<message:N>\0" */
+ const char *tag = "";
+ const char *message= "";
+ if(log_msg.entry.len > 1)
+ tag = log_msg.msg() + 1;
+ if (log_msg.entry.len > 1 + strlen(tag) + 1)
+ message = tag + strlen(tag) + 1;
+
uint32_t ts;
ts = get_timestamp_from_log_msg(&log_msg);