aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornguo <nana.n.guo@intel.com>2012-02-23 17:02:00 +0800
committerPatrick Tjin <pattjin@google.com>2014-07-21 22:03:38 -0700
commit06d2b4622ddb4b2f9ae3bd5eefd4d991c5d69367 (patch)
tree633798c03c6d03faed3b335171ef4a7f3e442e3c
parent705c231d1e4ff148d8cec637288d9ad41429f0e3 (diff)
downloadwrs_omxil_core-06d2b4622ddb4b2f9ae3bd5eefd4d991c5d69367.tar.gz
wrs_omxil_core: Critical Klocwork issues
BZ: 23921 modify strnpy for length check Signed-off-by: nguo <nana.n.guo@intel.com> Change-Id: If1712c127251c6392ddb12f7ae7ee92d85c3e567 Reviewed-on: http://android.intel.com:8080/36375 Reviewed-by: Ding, Haitao <haitao.ding@intel.com> Tested-by: Ding, Haitao <haitao.ding@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
-rw-r--r--base/src/cmodule.cpp3
-rw-r--r--base/src/componentbase.cpp3
2 files changed, 4 insertions, 2 deletions
diff --git a/base/src/cmodule.cpp b/base/src/cmodule.cpp
index 002648a..cca5332 100644
--- a/base/src/cmodule.cpp
+++ b/base/src/cmodule.cpp
@@ -42,7 +42,8 @@ CModule::CModule(const OMX_STRING lname)
memset(cname, 0, OMX_MAX_STRINGNAME_SIZE);
memset(this->lname, 0, OMX_MAX_STRINGNAME_SIZE);
- strncpy(this->lname, lname, OMX_MAX_STRINGNAME_SIZE);
+ // strncpy(this->name, name, OMX_MAX_STRINGNAME_SIZE);
+ strncpy(this->lname, lname, (strlen(lname) < OMX_MAX_STRINGNAME_SIZE) ? strlen(lname) : OMX_MAX_STRINGNAME_SIZE);
this->lname[OMX_MAX_STRINGNAME_SIZE-1] = '\0';
}
diff --git a/base/src/componentbase.cpp b/base/src/componentbase.cpp
index f282ca1..98bcf53 100644
--- a/base/src/componentbase.cpp
+++ b/base/src/componentbase.cpp
@@ -168,7 +168,8 @@ ComponentBase::~ComponentBase()
/* name */
void ComponentBase::SetName(const OMX_STRING name)
{
- strncpy(this->name, name, OMX_MAX_STRINGNAME_SIZE);
+ strncpy(this->name, name, (strlen(name) < OMX_MAX_STRINGNAME_SIZE) ? strlen(name) : OMX_MAX_STRINGNAME_SIZE);
+ // strncpy(this->name, name, OMX_MAX_STRINGNAME_SIZE);
this->name[OMX_MAX_STRINGNAME_SIZE-1] = '\0';
}