diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-02-21 13:36:19 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-02-21 15:30:25 +0000 |
commit | f19dd9ad207491edc9fb169676a307da237a11c6 (patch) | |
tree | 3ebdba41b78a48c5584a11dbda765e50308489c0 /cui | |
parent | coverity#705963 Dereference before null check (diff) | |
download | core-f19dd9ad207491edc9fb169676a307da237a11c6.tar.gz core-f19dd9ad207491edc9fb169676a307da237a11c6.zip |
coverity#706146 Copy into fixed size buffer
Change-Id: I1d774cff476a2ce7fe1e4b4ba1e64bc42a6ff27e
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/optinet2.cxx | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index 31c37eb39783..382d902f5c88 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -980,18 +980,16 @@ sal_Bool MozPluginTabPage::isInstalled() { #ifdef UNIX // get the real file referred by .so lnk file - char lnkFilePath[NPP_PATH_MAX] = {0}; char lnkReferFilePath[NPP_PATH_MAX] = {0}; char* pHome = getpwuid(getuid())->pw_dir; - strcat(lnkFilePath, pHome); - strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION); + OString lnkFilePath(OString(pHome) + OString("/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION)); struct stat sBuf; - if (0 > lstat(lnkFilePath, &sBuf)) + if (0 > lstat(lnkFilePath.getStr(), &sBuf)) return false; if (!S_ISLNK(sBuf.st_mode)) return false; - if (0 >= readlink(lnkFilePath, lnkReferFilePath, NPP_PATH_MAX)) + if (0 >= readlink(lnkFilePath.getStr(), lnkReferFilePath, NPP_PATH_MAX)) return false; // If the link is relative, then we regard it as non-standard if (lnkReferFilePath[0] != '/') @@ -1031,17 +1029,15 @@ sal_Bool MozPluginTabPage::installPlugin() { #ifdef UNIX // get the real file referred by .so lnk file - char lnkFilePath[NPP_PATH_MAX] = {0}; char* pHome = getpwuid(getuid())->pw_dir; - strcat(lnkFilePath, pHome); - strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION); - remove(lnkFilePath); + OString lnkFilePath(OString(pHome) + OString("/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION)); + remove(lnkFilePath.getStr()); // create the dirs if necessary struct stat buf; char tmpDir[NPP_PATH_MAX] = {0}; sprintf(tmpDir, "%s/.mozilla", pHome); - if (0 > stat(lnkFilePath, &buf)) + if (0 > stat(lnkFilePath.getStr(), &buf)) { mkdir(tmpDir, 0755); strcat(tmpDir, "/plugins"); @@ -1058,7 +1054,7 @@ sal_Bool MozPluginTabPage::installPlugin() strcat(realFilePath, "/libnpsoplugin" SAL_DLLEXTENSION); // create the link - if (0 != symlink(realFilePath, lnkFilePath)) + if (0 != symlink(realFilePath, lnkFilePath.getStr())) return false; return true; #endif @@ -1080,12 +1076,10 @@ sal_Bool MozPluginTabPage::uninstallPlugin() { #ifdef UNIX // get the real file referred by .so lnk file - char lnkFilePath[NPP_PATH_MAX] = {0}; char* pHome = getpwuid(getuid())->pw_dir; - strcat(lnkFilePath, pHome); - strcat(lnkFilePath, "/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION); + OString lnkFilePath(OString(pHome) + OString("/.mozilla/plugins/libnpsoplugin" SAL_DLLEXTENSION)); - if(0 > remove(lnkFilePath)) + if(0 > remove(lnkFilePath.getStr())) return false; return true; #endif |