Commits

Joe committed d82ad0357ff
Fixed buffer overflow in demangler Changing the name of ErrorProtocol to Error broke this runtime test — causing a buffer overflow. The mangled name changed from _TtPs13ErrorProtocol_->_TtPs5Error_ but the strlen didn’t change from 21 to 12; I update the callers to use static string length instead of a literal string & length. Error reported is: ================================================================= ==88865==ERROR: AddressSanitizer: global-buffer-overflow on address 0x0001028ba40d at pc 0x000103291a1f bp 0x7fff5d3492c0 sp 0x7fff5d348a80 READ of size 9 at 0x0001028ba40d thread T0 (libclang_rt.asan_osx_dynamic.dylib+0x42a1e) std::__1::char_traits<char>, std::__1::allocator<char> >::__init(char const*, unsigned long) (libc++.1.dylib+0x3f224) swift::Demangle::NodeFactory::create(swift::Demangle::Node::Kind, llvm::StringRef) string:2044 namespace)::Demangler::demangleTopLevel() Demangle.cpp:358 unsigned long, swift::Demangle::DemangleOptions const&) Demangle.cpp:2288 MetadataReader.h:772 0x0001028ba40d is located 51 bytes to the left of global variable '<string literal>' defined in '/Users/buildslave/jenkins/workspace/swift-incremental-asan-RDA/swift/to ols/swift-reflection-test/swift-reflection-test.c:458:19' (0x1028ba440) of size 41 '<string literal>' is ascii string 'swift-reflection-test <binary filename> ' 0x0001028ba40d is located 0 bytes to the right of global variable '<string literal>' defined in '/Users/buildslave/jenkins/workspace/swift-incremental-asan-RDA/swift/to ols/swift-reflection-test/swift-reflection-test.c:435:15' (0x1028ba400) of size 13 '<string literal>' is ascii string '_TtPs5Error_' SUMMARY: AddressSanitizer: global-buffer-overflow (libclang_rt.asan_osx_dynamic.dylib+0x42a1e) in wrap_memmove