From 52a845523e6a7bb8d8a4ac65f639598d82bf0be6 Mon Sep 17 00:00:00 2001 From: Katz Yamada Date: Sun, 3 Nov 2019 11:45:02 +0200 Subject: [PATCH] msm8226-common: gps: Fix for buffer overrun crash at copying nmea string Add zero clearing of allocated nmea buffer to ensure the nmea string is null terminated. Change-Id: I78e8b03bc7d0f9b69e1a51356da379a57a647cad CRs-Fixed: 2041933 --- gps/loc_api/libloc_api_50001/loc_eng.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gps/loc_api/libloc_api_50001/loc_eng.cpp b/gps/loc_api/libloc_api_50001/loc_eng.cpp index af97c51..0aa1c8b 100644 --- a/gps/loc_api/libloc_api_50001/loc_eng.cpp +++ b/gps/loc_api/libloc_api_50001/loc_eng.cpp @@ -891,9 +891,9 @@ inline void LocEngReportStatus::log() const { // case LOC_ENG_MSG_REPORT_NMEA: LocEngReportNmea::LocEngReportNmea(void* locEng, const char* data, int len) : - LocMsg(), mLocEng(locEng), mNmea(new char[len]), mLen(len) + LocMsg(), mLocEng(locEng), mNmea(new char[len+1]), mLen(len) { - memcpy((void*)mNmea, (void*)data, len); + strlcpy(mNmea, data, len+1); locallog(); } void LocEngReportNmea::proc() const {