From 09df76443e464b64eea650feee384f06d9deec88 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 10 Dec 2014 02:10:35 +0000 Subject: [PATCH] AsmParser: Don't allow null bytes in BB labels Since Value objects can't have null bytes in their name, we shouldn't allow them in the labels of basic blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223907 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AsmParser/LLLexer.cpp | 7 ++++++- test/Assembler/invalid-name2.ll | Bin 0 -> 120 bytes 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 test/Assembler/invalid-name2.ll diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp index cd7f09b8933..ca3c9e8b6f8 100644 --- a/lib/AsmParser/LLLexer.cpp +++ b/lib/AsmParser/LLLexer.cpp @@ -393,7 +393,12 @@ lltok::Kind LLLexer::LexQuote() { if (CurPtr[0] == ':') { ++CurPtr; - kind = lltok::LabelStr; + if (StringRef(StrVal).find_first_of(0) != StringRef::npos) { + Error("Null bytes are not allowed in names"); + kind = lltok::Error; + } else { + kind = lltok::LabelStr; + } } return kind; diff --git a/test/Assembler/invalid-name2.ll b/test/Assembler/invalid-name2.ll new file mode 100644 index 0000000000000000000000000000000000000000..384dee6777d805466166edf9db309eb75c3de521 GIT binary patch literal 120 zcmW;DK?=e!5Cu@zbBa$v(S-|LrXoUU5d;^42asfngE3Q@u?Xtj6}Jywjnnz)kkydV zcwb%$HkcNyx3d-AXeF_~a=87BC~_y6F{(uDI?NY%Q8lR?)$seq9~}7Eb1;sOTx@s* R6V1>*Xk-EgwtuD%eE~+FBr^a2 literal 0 HcmV?d00001