This patch by Chris Manghane fixes the Go frontend to avoid a possible
out of bounds memcmp when looking for a go:nointerface comment. This
fixes https://golang.org/issue/11577 . Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE (revision 227696)
+++ gcc/go/gofrontend/MERGE (working copy)
@@ -1,4 +1,4 @@
-352617bfe0a880febf5d2a87e89ea439c742ba18
+aea4360ca9c37f8e929f177ae7e42593ee62aa79
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
Index: gcc/go/gofrontend/lex.cc
===================================================================
--- gcc/go/gofrontend/lex.cc (revision 227696)
+++ gcc/go/gofrontend/lex.cc (working copy)
@@ -1752,7 +1752,9 @@ Lex::skip_cpp_comment()
// For field tracking analysis: a //go:nointerface comment means
// that the next interface method should not be stored in the type
// descriptor. This permits it to be discarded if it is not needed.
- if (this->lineoff_ == 2 && memcmp(p, "go:nointerface", 14) == 0)
+ if (this->lineoff_ == 2
+ && pend - p > 14
+ && memcmp(p, "go:nointerface", 14) == 0)
this->saw_nointerface_ = true;
while (p < pend)