Merge branch 'master' into maps

pull/13171/head
Joshua Haberman 6 years ago
commit 18de110b00
  1. 24
      BUILD
  2. 8
      bazel/upb_proto_library.bzl
  3. 15
      tests/file_descriptor_parsenew_fuzzer.cc
  4. 6
      tools/make_cmakelists.py

24
BUILD

@ -43,6 +43,11 @@ config_setting(
visibility = ["//visibility:public"],
)
config_setting(
name = "fuzz",
values = {"define": "fuzz=true"},
)
# Public C/C++ libraries #######################################################
cc_library(
@ -356,6 +361,25 @@ cc_test(
],
)
# OSS-Fuzz test
cc_binary(
testonly = 1,
name = "file_descriptor_parsenew_fuzzer",
srcs = ["tests/file_descriptor_parsenew_fuzzer.cc"],
copts = CPPOPTS + select({
"//conditions:default": [],
":fuzz": ["-fsanitizer=fuzzer,address"],
}),
defines = select({
"//conditions:default": [],
":fuzz": ["HAVE_FUZZER"],
}),
deps = [
":descriptor_upbproto",
":upb",
],
)
# copybara:strip_for_google3_begin
upb_proto_reflection_library(
name = "descriptor_upbreflection",

@ -37,10 +37,8 @@ def _get_real_roots(files):
return roots.keys()
def _generate_output_file(ctx, src, extension):
if _is_bazel:
real_short_path = _get_real_short_path(src)
else:
real_short_path = paths.relativize(src.short_path, ctx.label.package)
real_short_path = _get_real_short_path(src)
real_short_path = paths.relativize(real_short_path, ctx.label.package)
output_filename = paths.replace_extension(real_short_path, extension)
ret = ctx.actions.declare_file(output_filename)
return ret
@ -177,7 +175,7 @@ def _upb_proto_rule_impl(ctx):
"_WrappedGeneratedSrcs (aspect should have handled this).")
cc_info = dep[_WrappedCcInfo].cc_info
srcs = dep[_WrappedGeneratedSrcs].srcs
lib = cc_info.linking_context.libraries_to_link[0]
lib = cc_info.linking_context.libraries_to_link.to_list()[0]
files = _filter_none([
lib.static_library,
lib.pic_static_library,

@ -0,0 +1,15 @@
#include <cstdint>
#include "google/protobuf/descriptor.upb.h"
#include "upb/upb.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
upb::Arena arena;
google_protobuf_FileDescriptorProto_parse(reinterpret_cast<const char*>(data),
size, arena.ptr());
return 0;
}
#ifndef HAVE_FUZZER
int main() {}
#endif

@ -48,7 +48,7 @@ class BuildFileFunctions(object):
else:
print("Warning: no such file: " + file)
if filter(IsSourceFile, files):
if list(filter(IsSourceFile, files)):
# Has sources, make this a normal library.
self.converter.toplevel += "add_library(%s\n %s)\n" % (
kwargs["name"],
@ -272,8 +272,8 @@ def GetDict(obj):
globs = GetDict(converter)
execfile("WORKSPACE", GetDict(WorkspaceFileFunctions(converter)))
execfile("BUILD", GetDict(BuildFileFunctions(converter)))
exec(open("WORKSPACE").read(), GetDict(WorkspaceFileFunctions(converter)))
exec(open("BUILD").read(), GetDict(BuildFileFunctions(converter)))
with open(sys.argv[1], "w") as f:
f.write(converter.convert())

Loading…
Cancel
Save