From 64939761628c1bf2b389877bfd1618f8d1dfba65 Mon Sep 17 00:00:00 2001 From: Shuicheng Lin Date: Sat, 26 Jan 2019 01:19:38 +0800 Subject: [PATCH] fix issue: fmClient segfaults on short string parameter It is due to out of range access violation. Fix it by checking length before access. Closes-Bug: 1807986 Change-Id: Iba2b445f50fd98a74d932c9b3f691fc7145274bb Signed-off-by: Shuicheng Lin --- fm-common/sources/fmAlarmUtils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fm-common/sources/fmAlarmUtils.cpp b/fm-common/sources/fmAlarmUtils.cpp index 9946aedb..8d204ddc 100644 --- a/fm-common/sources/fmAlarmUtils.cpp +++ b/fm-common/sources/fmAlarmUtils.cpp @@ -205,6 +205,8 @@ static std::string chkstr(const std::string &s) { static void str_to_vector(const std::string &s, std::vector &alarm) { size_t offset = 0; alarm.clear(); + if (s.length() <= 3) + return ; while (true) { size_t beg = (offset==0) ? 0 : s.find("###",offset); if (beg==std::string::npos) break;