From 2cd234bc9319f8e586a74c2b152043501e1d4b4c Mon Sep 17 00:00:00 2001 From: Jonathan Metzman Date: Fri, 10 May 2019 22:26:11 +0000 Subject: [PATCH] [unrar] Fix fuzzer build breakage. Bug: 961748 Change-Id: I1d7067e8c2142abeb9497b1ac2c096fad2bcd157 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1605166 Commit-Queue: Jonathan Metzman Commit-Queue: Varun Khaneja Reviewed-by: Varun Khaneja Auto-Submit: Jonathan Metzman Cr-Commit-Position: refs/heads/master@{#658786} --- third_party/unrar/BUILD.gn | 45 +++++++++++++++++-------------- third_party/unrar/unrar_fuzzer.cc | 3 --- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/third_party/unrar/BUILD.gn b/third_party/unrar/BUILD.gn index e64f9a82f55230..cabb1f891692c8 100644 --- a/third_party/unrar/BUILD.gn +++ b/third_party/unrar/BUILD.gn @@ -66,25 +66,10 @@ if (safe_browsing_mode == 1 || use_fuzzing_engine) { "//build/config/compiler:no_chromium_code", # This must be after no_chromium_code for warning flags to be ordered correctly - ":unrar_warnings", + ":unrar_config", ] - defines = [ - "_FILE_OFFSET_BITS=64", - "LARGEFILE_SOURCE", - "RAR_SMP", - "SILENT", - "NOVOLUME", - - # The following is set to disable certain macro definitions in the unrar - # source code. - "CHROMIUM_UNRAR", - ] - - if (!use_libfuzzer) { - # Disables exceptions in unrar, replaces them with process termination. - defines += [ "UNRAR_NO_EXCEPTIONS" ] - } else { + if (use_libfuzzer) { configs -= [ "//build/config/compiler:no_exceptions" ] } @@ -102,13 +87,19 @@ if (safe_browsing_mode == 1 || use_fuzzing_engine) { ":unrar", ] include_dirs = [ "//third_party/unrar/src" ] - defines = [ "CHROMIUM_UNRAR" ] - configs_to_remove = [ "//build/config/compiler:no_exceptions" ] + additional_configs = [ + "//build/config/compiler:no_chromium_code", + ":unrar_config", + ] + configs_to_remove = [ + "//build/config/compiler:no_exceptions", + "//build/config/compiler:chromium_code", + ] } } } -config("unrar_warnings") { +config("unrar_config") { cflags = [ # unrar frequently drops parentheses around logical ops "-Wno-logical-op-parentheses", @@ -125,4 +116,18 @@ config("unrar_warnings") { # unrar has missing braces for initialization in rarvm.cpp "-Wno-missing-braces", ] + + defines = [ + "_FILE_OFFSET_BITS=64", + "LARGEFILE_SOURCE", + "RAR_SMP", + "SILENT", + "NOVOLUME", + "CHROMIUM_UNRAR", + ] + + if (!use_libfuzzer) { + # Disables exceptions in unrar, replaces them with process termination. + defines += [ "UNRAR_NO_EXCEPTIONS" ] + } } diff --git a/third_party/unrar/unrar_fuzzer.cc b/third_party/unrar/unrar_fuzzer.cc index fb8f776edace96..61b59f1217e58f 100644 --- a/third_party/unrar/unrar_fuzzer.cc +++ b/third_party/unrar/unrar_fuzzer.cc @@ -13,9 +13,6 @@ #include "rar.hpp" -using third_party_unrar::CmdExtract; -using third_party_unrar::CommandData; - static int removeFile(const char* fpath, const struct stat* sb, int typeflag,