summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-05-14 19:40:50 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-05-14 22:55:47 +0200
commit163e4686914ecf04f1cbef2f6a087cadbfe59f81 (patch)
tree0a111ea23874569bb20ce2508fc1710b97df0823
parent20f0ab23b1c0b60ca36a053464f3ba41bf27c80e (diff)
ofz#47323 suppress Direct-leak
__lsan_default_suppressions works in a local oss-fuzz image but seems to have no effect when deployed which fits with the report of https://github.com/google/oss-fuzz/issues/6066 try explicit __lsan_disable/__lsan_enable guards which also works locally Change-Id: Ifbfdb9d9ba7014b78b43578c25fca97c3279bc5d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134331 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/unx/generic/gdi/cairotextrender.cxx18
-rw-r--r--vcl/workben/svmfuzzer.cxx5
2 files changed, 18 insertions, 5 deletions
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 31c2a73c2eb4..0be33e9436c9 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -117,6 +117,14 @@ namespace
}
}
+#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
+extern "C"
+{
+ __attribute__((weak)) void __lsan_disable();
+ __attribute__((weak)) void __lsan_enable();
+}
+#endif
+
void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalGraphics& rGraphics)
{
const FreetypeFontInstance& rInstance = static_cast<FreetypeFontInstance&>(rLayout.GetFont());
@@ -178,6 +186,11 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
return;
}
+#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
+ if (__lsan_disable)
+ __lsan_disable();
+#endif
+
if (const cairo_font_options_t* pFontOptions = GetSalInstance()->GetCairoFontOptions())
{
const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
@@ -305,6 +318,11 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
}
releaseCairoContext(cr);
+
+#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
+ if (__lsan_enable)
+ __lsan_enable();
+#endif
}
void FontConfigFontOptions::cairo_font_options_substitute(FcPattern* pPattern)
diff --git a/vcl/workben/svmfuzzer.cxx b/vcl/workben/svmfuzzer.cxx
index f0c129e76cd4..53757e3199c7 100644
--- a/vcl/workben/svmfuzzer.cxx
+++ b/vcl/workben/svmfuzzer.cxx
@@ -73,11 +73,6 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
return 0;
}
-extern "C" const char* __lsan_default_suppressions()
-{
- return "leak:CairoTextRender::DrawTextLayout\n";
-}
-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);