aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-12-03 12:13:22 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-12-03 12:13:22 +0000
commite4886f22217582ae3a6e073d4f448cf206187bc4 (patch)
tree71192bb82325d2c232d5126284a48ba627dd7712
parent11047db2ac278e3e6daf4454288214dce8ecd364 (diff)
parentf5e6ed34b3e7e379731990c25d0a5f10dde6b47d (diff)
downloadlibprotobuf-mutator-e4886f22217582ae3a6e073d4f448cf206187bc4.tar.gz
Upgrade libprotobuf-mutator to e5869dd9690c3f4dfb842fb90bd07a5a9ee32172 am: 18b7d3da64 am: f5e6ed34b3
Original change: https://android-review.googlesource.com/c/platform/external/libprotobuf-mutator/+/1516138 Change-Id: Ia1cd62c93d0f9a40e908f8cc96b4687dc4a7b2c7
-rw-r--r--CMakeLists.txt5
-rw-r--r--METADATA6
-rw-r--r--cmake/external/googletest.cmake1
-rw-r--r--cmake/external/protobuf.cmake1
-rw-r--r--libprotobuf-mutator.pc.in3
-rw-r--r--libprotobuf-mutatorConfig.cmake.in5
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/libfuzzer/CMakeLists.txt4
-rw-r--r--src/libfuzzer/libfuzzer_mutator.cc5
9 files changed, 25 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d9be154..a8fe9e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,6 +150,11 @@ if (NOT "${LIB_PROTO_MUTATOR_FUZZER_LIBRARIES}" STREQUAL "" OR
add_subdirectory(examples EXCLUDE_FROM_ALL)
endif()
+install(EXPORT libprotobuf-mutatorTargets FILE libprotobuf-mutatorTargets.cmake
+ NAMESPACE libprotobuf-mutator:: DESTINATION lib/cmake/libprotobuf-mutator)
+configure_file(libprotobuf-mutatorConfig.cmake.in libprotobuf-mutatorConfig.cmake @ONLY)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libprotobuf-mutatorConfig.cmake"
+ DESTINATION lib/cmake/libprotobuf-mutator)
configure_file("libprotobuf-mutator.pc.in" "libprotobuf-mutator.pc" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}/libprotobuf-mutator.pc"
DESTINATION ${PKG_CONFIG_PATH})
diff --git a/METADATA b/METADATA
index 424db9c..9d1a715 100644
--- a/METADATA
+++ b/METADATA
@@ -5,11 +5,11 @@ third_party {
type: GIT
value: "https://github.com/google/libprotobuf-mutator"
}
- version: "8942a9ba43d8bb196230c321d46d6a137957a719"
+ version: "e5869dd9690c3f4dfb842fb90bd07a5a9ee32172"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 8
- day: 29
+ month: 12
+ day: 2
}
}
diff --git a/cmake/external/googletest.cmake b/cmake/external/googletest.cmake
index 3c3f8cf..825ff9a 100644
--- a/cmake/external/googletest.cmake
+++ b/cmake/external/googletest.cmake
@@ -50,5 +50,6 @@ ExternalProject_Add(${GTEST_TARGET}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
CMAKE_ARGS ${CMAKE_ARGS}
-DCMAKE_INSTALL_PREFIX=${GTEST_INSTALL_DIR}
+ -DCMAKE_INSTALL_LIBDIR=lib
BUILD_BYPRODUCTS ${GTEST_BUILD_BYPRODUCTS}
)
diff --git a/cmake/external/protobuf.cmake b/cmake/external/protobuf.cmake
index 52a3f47..0b64519 100644
--- a/cmake/external/protobuf.cmake
+++ b/cmake/external/protobuf.cmake
@@ -68,6 +68,7 @@ ExternalProject_Add(${PROTOBUF_TARGET}
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${PROTOBUF_INSTALL_DIR}/src/${PROTOBUF_TARGET}/cmake
-G${CMAKE_GENERATOR}
-DCMAKE_INSTALL_PREFIX=${PROTOBUF_INSTALL_DIR}
+ -DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
diff --git a/libprotobuf-mutator.pc.in b/libprotobuf-mutator.pc.in
index ac5224e..551dc72 100644
--- a/libprotobuf-mutator.pc.in
+++ b/libprotobuf-mutator.pc.in
@@ -1,8 +1,9 @@
prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${prefix}/lib
includedir=${prefix}/include/libprotobuf-mutator
Name: libprotobuf-mutator
Description: randomly mutate protobuffers for fuzzing
Version: 0
Cflags: -I${includedir} -I${includedir}/src
-Libs: -lprotobuf-mutator-libfuzzer -lprotobuf-mutator
+Libs: -L${libdir} -lprotobuf-mutator-libfuzzer -lprotobuf-mutator
diff --git a/libprotobuf-mutatorConfig.cmake.in b/libprotobuf-mutatorConfig.cmake.in
new file mode 100644
index 0000000..f62a501
--- /dev/null
+++ b/libprotobuf-mutatorConfig.cmake.in
@@ -0,0 +1,5 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(Protobuf REQUIRED)
+
+include("${CMAKE_CURRENT_LIST_DIR}/libprotobuf-mutatorTargets.cmake")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 19f4406..d0af1b6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -60,5 +60,7 @@ if (LIB_PROTO_MUTATOR_TESTING)
endif()
install(TARGETS protobuf-mutator
+ EXPORT libprotobuf-mutatorTargets
ARCHIVE DESTINATION ${LIB_DIR}
- LIBRARY DESTINATION ${LIB_DIR})
+ LIBRARY DESTINATION ${LIB_DIR}
+ INCLUDES DESTINATION include/libprotobuf-mutator include/libprotobuf-mutator/src)
diff --git a/src/libfuzzer/CMakeLists.txt b/src/libfuzzer/CMakeLists.txt
index 8fc78e6..85e9f4d 100644
--- a/src/libfuzzer/CMakeLists.txt
+++ b/src/libfuzzer/CMakeLists.txt
@@ -23,8 +23,10 @@ set_target_properties(protobuf-mutator-libfuzzer PROPERTIES
SOVERSION 0)
install(TARGETS protobuf-mutator-libfuzzer
+ EXPORT libprotobuf-mutatorTargets
ARCHIVE DESTINATION ${LIB_DIR}
- LIBRARY DESTINATION ${LIB_DIR})
+ LIBRARY DESTINATION ${LIB_DIR}
+ INCLUDES DESTINATION include/libprotobuf-mutator include/libprotobuf-mutator/src)
if (LIB_PROTO_MUTATOR_TESTING)
add_executable(libfuzzer_test
diff --git a/src/libfuzzer/libfuzzer_mutator.cc b/src/libfuzzer/libfuzzer_mutator.cc
index c8bca64..34d144c 100644
--- a/src/libfuzzer/libfuzzer_mutator.cc
+++ b/src/libfuzzer/libfuzzer_mutator.cc
@@ -89,9 +89,8 @@ std::string Mutator::MutateString(const std::string& value,
// any 8 bit types.
if (!std::uniform_int_distribution<uint16_t>(0, 20)(*random())) return {};
std::string result = value;
- result.resize(value.size() +
- std::max<int>(-value.size(), size_increase_hint));
- if (result.empty()) result.push_back(0);
+ int new_size = value.size() + size_increase_hint;
+ result.resize(std::max(1, new_size));
result.resize(LLVMFuzzerMutate(reinterpret_cast<uint8_t*>(&result[0]),
value.size(), result.size()));
return result;