summaryrefslogtreecommitdiff
path: root/lib/gwp_asan
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2019-08-22 07:03:38 +0000
committerPetr Hosek <phosek@chromium.org>2019-08-22 07:03:38 +0000
commit784073907c0695388e672350a7741c35bdd23034 (patch)
treeacd621f0caffbf81a574de2f50dd685909190032 /lib/gwp_asan
parent0f9ca8d128e2a7e6ad77676d18ee0753f3902ba7 (diff)
downloadcompiler-rt-784073907c0695388e672350a7741c35bdd23034.tar.gz
Revert "[GWP-ASan] Remove c++ standard lib dependency."
This reverts commit r369606: this doesn't addressed the underlying problem and it's not the correct solution. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@369623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/gwp_asan')
-rw-r--r--lib/gwp_asan/CMakeLists.txt7
-rw-r--r--lib/gwp_asan/stack_trace_compressor_fuzzer.cpp27
2 files changed, 17 insertions, 17 deletions
diff --git a/lib/gwp_asan/CMakeLists.txt b/lib/gwp_asan/CMakeLists.txt
index 21b36e749..3db583c30 100644
--- a/lib/gwp_asan/CMakeLists.txt
+++ b/lib/gwp_asan/CMakeLists.txt
@@ -108,11 +108,8 @@ if (COMPILER_RT_HAS_GWP_ASAN)
${GWP_ASAN_HEADERS})
set_target_properties(
stack_trace_compressor_fuzzer PROPERTIES FOLDER "Fuzzers")
-
- # TODO(phosek): Remove -nostdlib++ and remove the "no c++ standard library
- # for compiler-rt" dependency here.
- target_compile_options(stack_trace_compressor_fuzzer
- PRIVATE -nostdlib++ -fsanitize=fuzzer-no-link)
+ target_compile_options(
+ stack_trace_compressor_fuzzer PRIVATE -fsanitize=fuzzer-no-link)
set_target_properties(
stack_trace_compressor_fuzzer PROPERTIES LINK_FLAGS -fsanitize=fuzzer)
add_dependencies(stack_trace_compressor_fuzzer fuzzer)
diff --git a/lib/gwp_asan/stack_trace_compressor_fuzzer.cpp b/lib/gwp_asan/stack_trace_compressor_fuzzer.cpp
index a6249ac6f..aa57fdaff 100644
--- a/lib/gwp_asan/stack_trace_compressor_fuzzer.cpp
+++ b/lib/gwp_asan/stack_trace_compressor_fuzzer.cpp
@@ -1,7 +1,8 @@
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstddef>
+#include <cstdint>
+#include <cstdio>
+#include <cstdlib>
+#include <vector>
#include "gwp_asan/stack_trace_compressor.h"
@@ -9,22 +10,23 @@ constexpr size_t kBytesForLargestVarInt = (sizeof(uintptr_t) * 8) / 7 + 1;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
size_t BufferSize = kBytesForLargestVarInt * Size / sizeof(uintptr_t);
- uint8_t *Buffer = reinterpret_cast<uint8_t *>(malloc(BufferSize));
- uint8_t *Buffer2 = reinterpret_cast<uint8_t *>(malloc(BufferSize));
+ std::vector<uint8_t> Buffer(BufferSize);
+ std::vector<uint8_t> Buffer2(BufferSize);
// Unpack the fuzz bytes.
gwp_asan::compression::unpack(Data, Size,
- reinterpret_cast<uintptr_t *>(Buffer2),
+ reinterpret_cast<uintptr_t *>(Buffer2.data()),
BufferSize / sizeof(uintptr_t));
// Pack the fuzz bytes.
- size_t BytesWritten =
- gwp_asan::compression::pack(reinterpret_cast<const uintptr_t *>(Data),
- Size / sizeof(uintptr_t), Buffer, BufferSize);
+ size_t BytesWritten = gwp_asan::compression::pack(
+ reinterpret_cast<const uintptr_t *>(Data), Size / sizeof(uintptr_t),
+ Buffer.data(), BufferSize);
// Unpack the compressed buffer.
size_t DecodedElements = gwp_asan::compression::unpack(
- Buffer, BytesWritten, reinterpret_cast<uintptr_t *>(Buffer2),
+ Buffer.data(), BytesWritten,
+ reinterpret_cast<uintptr_t *>(Buffer2.data()),
BufferSize / sizeof(uintptr_t));
// Ensure that every element was encoded and decoded properly.
@@ -33,7 +35,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
// Ensure that the compression and uncompression resulted in the same trace.
const uintptr_t *FuzzPtrs = reinterpret_cast<const uintptr_t *>(Data);
- const uintptr_t *DecodedPtrs = reinterpret_cast<const uintptr_t *>(Buffer2);
+ const uintptr_t *DecodedPtrs =
+ reinterpret_cast<const uintptr_t *>(Buffer2.data());
for (size_t i = 0; i < Size / sizeof(uintptr_t); ++i) {
if (FuzzPtrs[i] != DecodedPtrs[i]) {
fprintf(stderr, "FuzzPtrs[%zu] != DecodedPtrs[%zu] (0x%zx vs. 0x%zx)", i,