Buffer not null terminated
authorKarol Pawlowski <k.pawlowski@samsung.com>
Mon, 25 Mar 2013 13:42:15 +0000 (14:42 +0100)
committerGerrit Code Review <gerrit2@kim11>
Tue, 26 Mar 2013 12:44:54 +0000 (21:44 +0900)
[Issue#] N/A
[Feature/Bug] N/A
[Problem]  The string buffer may not have a null terminator
[Cause] Coverity warnings
[Solution] Strings possible length decremented

Change-Id: I6b505ce2b72c6de944c4fa6e7c2e21cce1aeea71

src/pkg-manager/backendlib.cpp

index 53b2ba6..60eb9b0 100644 (file)
@@ -347,12 +347,12 @@ int getWidgetDetailInfoFromPackage(const char* pkgPath,
     strncpy(pkg_detail_info->pkg_type, "wgt", PKG_TYPE_STRING_LEN_MAX);
     if (!configInfo.tizenPkgId.IsNull()) {
         strncpy(pkg_detail_info->pkgid,
-                DPL::ToUTF8String(*configInfo.tizenPkgId).c_str(), PKG_TYPE_STRING_LEN_MAX);
+                DPL::ToUTF8String(*configInfo.tizenPkgId).c_str(), PKG_TYPE_STRING_LEN_MAX - 1);
     }
     if (!configInfo.version.IsNull()) {
         strncpy(pkg_detail_info->version,
                 DPL::ToUTF8String(*configInfo.version).c_str(),
-                PKG_VERSION_STRING_LEN_MAX);
+                PKG_VERSION_STRING_LEN_MAX - 1);
     }
 
     DPL::Optional<DPL::String> name;
@@ -376,7 +376,7 @@ int getWidgetDetailInfoFromPackage(const char* pkgPath,
     }
 
     if( !name.IsNull()) {
-        strncpy(pkg_detail_info->pkg_name, DPL::ToUTF8String(*name).c_str(), PKG_NAME_STRING_LEN_MAX);
+        strncpy(pkg_detail_info->pkg_name, DPL::ToUTF8String(*name).c_str(), PKG_NAME_STRING_LEN_MAX - 1);
     }
 
     if (!desc.IsNull()) {
@@ -394,7 +394,7 @@ int getWidgetDetailInfoFromPackage(const char* pkgPath,
     if (!configInfo.authorName.IsNull()) {
         strncpy(pkg_detail_info->author,
                 DPL::ToUTF8String(*configInfo.authorName).c_str(),
-                PKG_VALUE_STRING_LEN_MAX);
+                PKG_VALUE_STRING_LEN_MAX - 1);
     }
 
     std::string icon_name;