[Libreoffice-commits] core.git: i18nlangtag/source include/i18nlangtag unotools/source

Caolán McNamara caolanm at redhat.com
Fri Jan 5 19:22:10 UTC 2018


 i18nlangtag/source/languagetag/languagetag.cxx |   12 ++++++++++--
 include/i18nlangtag/languagetag.hxx            |    3 +++
 unotools/source/config/configmgr.cxx           |    2 ++
 3 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit cadfee0a72cf032314833959f7b7f3f6688a3079
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jan 5 15:15:15 2018 +0000

    ofz#4952 avoid liblangtag config when fuzzing enabled
    
    Change-Id: I9f2b0cbb5108f57ec2f80ebe24f748c33ea9cf59
    Reviewed-on: https://gerrit.libreoffice.org/47477
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index 28842ccace6d..f9945f10c5c9 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -702,6 +702,14 @@ void LanguageTag::setConfiguredSystemLanguage( LanguageType nLang )
     aLanguageTag.registerImpl();
 }
 
+static bool lt_tag_parse_disabled = false;
+
+// static
+void LanguageTag::disable_lt_tag_parse()
+{
+    lt_tag_parse_disabled = true;
+}
+
 static bool lcl_isKnownOnTheFlyID( LanguageType nLang )
 {
     return nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM &&
@@ -1197,7 +1205,7 @@ bool LanguageTagImpl::canonicalize()
 
     myLtError aError;
 
-    if (lt_tag_parse( mpImplLangtag, OUStringToOString( maBcp47, RTL_TEXTENCODING_UTF8).getStr(), &aError.p))
+    if (!lt_tag_parse_disabled && lt_tag_parse(mpImplLangtag, OUStringToOString(maBcp47, RTL_TEXTENCODING_UTF8).getStr(), &aError.p))
     {
         char* pTag = lt_tag_canonicalize( mpImplLangtag, &aError.p);
         SAL_WARN_IF( !pTag, "i18nlangtag", "LanguageTagImpl::canonicalize: could not canonicalize '" << maBcp47 << "'");
@@ -2809,7 +2817,7 @@ bool LanguageTag::isValidBcp47( const OUString& rString, OUString* o_pCanonicali
 
     myLtError aError;
 
-    if (lt_tag_parse( aVar.mpLangtag, OUStringToOString( rString, RTL_TEXTENCODING_UTF8).getStr(), &aError.p))
+    if (!lt_tag_parse_disabled && lt_tag_parse(aVar.mpLangtag, OUStringToOString(rString, RTL_TEXTENCODING_UTF8).getStr(), &aError.p))
     {
         char* pTag = lt_tag_canonicalize( aVar.mpLangtag, &aError.p);
         SAL_WARN_IF( !pTag, "i18nlangtag", "LanguageTag:isValidBcp47: could not canonicalize '" << rString << "'");
diff --git a/include/i18nlangtag/languagetag.hxx b/include/i18nlangtag/languagetag.hxx
index a9937205ef8c..f337d147b414 100644
--- a/include/i18nlangtag/languagetag.hxx
+++ b/include/i18nlangtag/languagetag.hxx
@@ -528,6 +528,9 @@ public:
     /** @ATTENTION: _ONLY_ to be called by the application's configuration! */
     static void setConfiguredSystemLanguage( LanguageType nLang );
 
+    /** @ATTENTION: _ONLY_ to be called by fuzzing setup */
+    static void disable_lt_tag_parse();
+
     typedef std::shared_ptr< LanguageTagImpl > ImplPtr;
 
 private:
diff --git a/unotools/source/config/configmgr.cxx b/unotools/source/config/configmgr.cxx
index 417bfc311bbf..1f83a94830d2 100644
--- a/unotools/source/config/configmgr.cxx
+++ b/unotools/source/config/configmgr.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <i18nlangtag/languagetag.hxx>
 #include <rtl/instance.hxx>
 #include <rtl/ustring.h>
 #include <rtl/ustring.hxx>
@@ -205,6 +206,7 @@ bool utl::ConfigManager::IsFuzzing()
 void utl::ConfigManager::EnableFuzzing()
 {
     bIsFuzzing = true;
+    LanguageTag::disable_lt_tag_parse();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list