Browse Source

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>
Shuicheng Lin 2 months ago
parent
commit
6493976162
1 changed files with 2 additions and 0 deletions
  1. 2
    0
      fm-common/sources/fmAlarmUtils.cpp

+ 2
- 0
fm-common/sources/fmAlarmUtils.cpp View File

@@ -205,6 +205,8 @@ static std::string chkstr(const std::string &s) {
205 205
 static void str_to_vector(const std::string &s, std::vector<std::string> &alarm) {
206 206
 	size_t offset = 0;
207 207
 	alarm.clear();
208
+	if (s.length() <= 3)
209
+		return ;
208 210
 	while (true) {
209 211
 		size_t beg = (offset==0) ? 0 : s.find("###",offset);
210 212
 		if (beg==std::string::npos) break;

Loading…
Cancel
Save