diff options
Diffstat (limited to 'comphelper/source/xml/xmltools.cxx')
-rw-r--r-- | comphelper/source/xml/xmltools.cxx | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/comphelper/source/xml/xmltools.cxx b/comphelper/source/xml/xmltools.cxx index 366321076bad..6ae8fceed5b9 100644 --- a/comphelper/source/xml/xmltools.cxx +++ b/comphelper/source/xml/xmltools.cxx @@ -9,7 +9,7 @@ #include <comphelper/xmltools.hxx> #include <rtl/random.h> -#include <rtl/uuid.h> +#include <tools/Guid.hxx> #include <vector> using namespace com::sun::star; @@ -71,17 +71,21 @@ namespace namespace comphelper::xml { + // Generate some 'chaff' of varying length to be the body of an + // XML comment to put at the start of encrypted content to make + // document content a little less predictable. + // See SvXMLExport::addChaffWhenEncryptedStorage OString makeXMLChaff() { rtlRandomPool pool = rtl_random_createPool(); sal_Int8 n; - rtl_random_getBytes(pool, &n, 1); + (void)rtl_random_getBytes(pool, &n, 1); sal_Int32 nLength = 1024+n; // coverity[tainted_data] - 1024 deliberate random minus max -127/plus max 128 std::vector<sal_uInt8> aChaff(nLength); - rtl_random_getBytes(pool, aChaff.data(), nLength); + (void)rtl_random_getBytes(pool, aChaff.data(), nLength); rtl_random_destroyPool(pool); @@ -92,15 +96,8 @@ namespace comphelper::xml OString generateGUIDString() { - sal_uInt8 aSeq[16]; - rtl_createUuid(aSeq, nullptr, true); - - char str[39]; - sprintf(str, "{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}", - aSeq[0], aSeq[1], aSeq[2], aSeq[3], aSeq[4], aSeq[5], aSeq[6], aSeq[7], aSeq[8], - aSeq[9], aSeq[10], aSeq[11], aSeq[12], aSeq[13], aSeq[14], aSeq[15]); - - return OString(str); + tools::Guid aGuid(tools::Guid::Generate); + return aGuid.getString(); } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |