[lld] r290160 - Fix a bug that the glob pattern parser falls in an infinite loop for invalid patterns.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 19 19:12:28 PST 2016
Author: ruiu
Date: Mon Dec 19 21:12:28 2016
New Revision: 290160
URL: http://llvm.org/viewvc/llvm-project?rev=290160&view=rev
Log:
Fix a bug that the glob pattern parser falls in an infinite loop for invalid patterns.
Modified:
lld/trunk/ELF/Strings.cpp
lld/trunk/test/ELF/version-script-complex-wildcards.s
Modified: lld/trunk/ELF/Strings.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Strings.cpp?rev=290160&r1=290159&r2=290160&view=diff
==============================================================================
--- lld/trunk/ELF/Strings.cpp (original)
+++ lld/trunk/ELF/Strings.cpp Mon Dec 19 21:12:28 2016
@@ -39,6 +39,7 @@ BitVector GlobPattern::scan(StringRef &S
size_t End = S.find(']', 1);
if (End == StringRef::npos) {
error("invalid glob pattern: " + Original);
+ S = "";
return BitVector(256, false);
}
StringRef Chars = S.substr(1, End - 1);
Modified: lld/trunk/test/ELF/version-script-complex-wildcards.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/version-script-complex-wildcards.s?rev=290160&r1=290159&r2=290160&view=diff
==============================================================================
--- lld/trunk/test/ELF/version-script-complex-wildcards.s (original)
+++ lld/trunk/test/ELF/version-script-complex-wildcards.s Mon Dec 19 21:12:28 2016
@@ -45,6 +45,11 @@
# RUN: ld.lld --version-script %t8.script -shared %t.o -o %t8.so
# RUN: llvm-readobj -V %t8.so | FileCheck %s --check-prefix=ABBABC
+# RUN: echo "FOO { global: extern \"C++\" { a[; }; };" > %t9.script
+# RUN: not ld.lld --version-script %t9.script -shared %t.o -o %t9.so 2>&1 \
+# RUN: | FileCheck %s --check-prefix=ERROR
+# ERROR: invalid glob pattern: a[
+
.text
.globl _Z3abci
.type _Z3abci, at function
More information about the llvm-commits
mailing list