[Libreoffice-commits] core.git: 2 commits - sal/osl sal/qa
Stephan Bergmann
sbergman at redhat.com
Tue Mar 4 04:50:05 PST 2014
sal/osl/unx/profile.cxx | 13 ++------
sal/qa/osl/profile/osl_old_testprofile.cxx | 43 ++++++++---------------------
2 files changed, 16 insertions(+), 40 deletions(-)
New commits:
commit 8f210c26c53cf5480819d983e57977d531422ff1
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Mar 4 13:47:20 2014 +0100
coverity#706154 is about call to strcpy, not osl_ProfileGenerateExtension
...and the call to strcpy isn't even necessary. This includes a revert of
430237b3fa16bda228ff82b93228f28894568671 "coverity#706154: Dest buffer too
small."
Change-Id: I51186da6e7d80438b01d49e24a1fa47877078516
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index 53f0757..2ee461e 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -2020,26 +2020,21 @@ static sal_Bool osl_ProfileSwapProfileNames(osl_TProfileImpl* pProfile)
sal_Char pszBakFile[PATH_MAX];
sal_Char pszTmpFile[PATH_MAX];
- sal_Char pszIniFile[PATH_MAX];
pszBakFile[0] = '\0';
pszTmpFile[0] = '\0';
- pszIniFile[0] = '\0';
- osl_ProfileGenerateExtension(pProfile->m_FileName, "bak", pszBakFile, PATH_MAX - 1);
-
- strcpy(pszIniFile, pProfile->m_FileName);
-
- osl_ProfileGenerateExtension(pProfile->m_FileName, "tmp", pszTmpFile, PATH_MAX - 1);
+ osl_ProfileGenerateExtension(pProfile->m_FileName, "bak", pszBakFile, PATH_MAX);
+ osl_ProfileGenerateExtension(pProfile->m_FileName, "tmp", pszTmpFile, PATH_MAX);
/* unlink bak */
unlink( pszBakFile );
/* rename ini bak */
- rename( pszIniFile, pszBakFile );
+ rename( pProfile->m_FileName, pszBakFile );
/* rename tmp ini */
- rename( pszTmpFile, pszIniFile );
+ rename( pszTmpFile, pProfile->m_FileName );
return bRet;
}
commit 3dcf6647109feeaa199e64d30a71407e225be582
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Mar 4 13:46:16 2014 +0100
Fix CppunitTest_sal_osl_profile
Change-Id: Ie66636881a2e4c754bd95f9d1d72e0b4fc2828df
diff --git a/sal/qa/osl/profile/osl_old_testprofile.cxx b/sal/qa/osl/profile/osl_old_testprofile.cxx
index 5bdeded..cc8fe8c 100644
--- a/sal/qa/osl/profile/osl_old_testprofile.cxx
+++ b/sal/qa/osl/profile/osl_old_testprofile.cxx
@@ -23,10 +23,8 @@
#include "cppunit/extensions/HelperMacros.h"
#include "cppunit/plugin/TestPlugIn.h"
-#include <stdio.h>
#include <osl/profile.h>
-
-
+#include <rtl/bootstrap.hxx>
namespace osl_Profile
{
@@ -42,36 +40,19 @@ namespace osl_Profile
void oldtests::test_profile(void)
{
- oslProfile hProfile;
- rtl_uString* ustrProfileName=0;
- rtl_uString* ustrProfileName2=0;
-
- rtl_uString_newFromAscii(&ustrProfileName,"//./tmp/soffice.ini");
- rtl_uString_newFromAscii(&ustrProfileName2,"//./tmp/not_existing_path/soffice.ini");
-
+ rtl::OUString baseUrl;
+ CPPUNIT_ASSERT(rtl::Bootstrap::get("UserInstallation", baseUrl));
// successful write
- hProfile = osl_openProfile( ustrProfileName, 0 );
- if (hProfile != 0)
- {
- if (! osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
- printf( "### cannot write into init file!\n" );
-
- osl_closeProfile( hProfile );
- }
-
- // unsuccessful write
- hProfile = osl_openProfile( ustrProfileName2, 0 );
- if (hProfile != 0)
- {
- if (osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
- printf( "### unexpected success writing into test2.ini!\n" );
-
- osl_closeProfile( hProfile );
- }
-
- rtl_uString_release(ustrProfileName);
- rtl_uString_release(ustrProfileName2);
+ oslProfile hProfile = osl_openProfile( rtl::OUString(baseUrl + "/soffice.ini").pData, osl_Profile_WRITELOCK );
+ CPPUNIT_ASSERT(hProfile != 0);
+ CPPUNIT_ASSERT_MESSAGE(
+ "cannot write into init file",
+ osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ));
+ CPPUNIT_ASSERT(osl_closeProfile( hProfile ));
+
+ // unsuccessful open
+ CPPUNIT_ASSERT_EQUAL(oslProfile(0), osl_openProfile( rtl::OUString(baseUrl + "/not_existing_path/soffice.ini").pData, osl_Profile_WRITELOCK ));
}
} // namespace osl_Profile
More information about the Libreoffice-commits
mailing list