summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShuicheng Lin <shuicheng.lin@intel.com>2019-01-26 01:19:38 +0800
committerShuicheng Lin <shuicheng.lin@intel.com>2019-01-29 02:25:12 +0800
commit64939761628c1bf2b389877bfd1618f8d1dfba65 (patch)
tree4aa1326e6c7996747b911cf82af386ca186520c6
parent80a9ad661f635ae566c69bd4c5dd3b609eac71e3 (diff)
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 <shuicheng.lin@intel.com>
Notes
Notes (review): Code-Review+1: Eric MacDonald <eric.macdonald@windriver.com> Code-Review+2: Tao Liu <tao.liu@windriver.com> Code-Review+2: Al Bailey <al.bailey@windriver.com> Workflow+1: Al Bailey <al.bailey@windriver.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 28 Jan 2019 20:32:29 +0000 Reviewed-on: https://review.openstack.org/633151 Project: openstack/stx-fault Branch: refs/heads/master
-rw-r--r--fm-common/sources/fmAlarmUtils.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/fm-common/sources/fmAlarmUtils.cpp b/fm-common/sources/fmAlarmUtils.cpp
index 9946aed..8d204dd 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) {
205static void str_to_vector(const std::string &s, std::vector<std::string> &alarm) { 205static void str_to_vector(const std::string &s, std::vector<std::string> &alarm) {
206 size_t offset = 0; 206 size_t offset = 0;
207 alarm.clear(); 207 alarm.clear();
208 if (s.length() <= 3)
209 return ;
208 while (true) { 210 while (true) {
209 size_t beg = (offset==0) ? 0 : s.find("###",offset); 211 size_t beg = (offset==0) ? 0 : s.find("###",offset);
210 if (beg==std::string::npos) break; 212 if (beg==std::string::npos) break;