From 586369fa6d8b7711fded955966a33b2ad6c4f6fe Mon Sep 17 00:00:00 2001 From: Erich Cordoba Date: Mon, 20 Aug 2018 12:01:50 -0500 Subject: [PATCH] Fix truncate string on STRCP_TO macro. The macro STRCP_TO copies a c_str into a char buffer, it won't copy more that sizeof(charb), however, the resulting string will be truncated. Although this is expected, the resulting string won't have a NULL terminator. Story: 2003497 Task: 24774 Change-Id: I249c75af897ba02837ad6d3981d976c291e88aea Signed-off-by: Erich Cordoba --- fm-common/sources/fmAlarmUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fm-common/sources/fmAlarmUtils.cpp b/fm-common/sources/fmAlarmUtils.cpp index 81c353be..0ae11120 100644 --- a/fm-common/sources/fmAlarmUtils.cpp +++ b/fm-common/sources/fmAlarmUtils.cpp @@ -42,7 +42,7 @@ static stoi_t err_to_int; ((str).length()==1 && ((str).c_str())[0]==' ')) { \ memset(charb,0,sizeof(charb)); \ } else { \ - strncpy((charb),str.c_str(),sizeof(charb)); \ + snprintf(charb, sizeof(charb)-1, "%s", str.c_str()); \ } void add_both_tables(int id, const char *str, itos_t &t1,stoi_t &t2 ) {