Dominik Vogt pointed out a problem in the Go frontend: it could
overwrite memory incorrectly if an archive contains a file whose name is
only spaces.  This patch fixes the problem.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and 4.9
branch.

Ian

diff -r e403fdfd3005 go/import-archive.cc
--- a/go/import-archive.cc	Fri Apr 25 20:32:52 2014 -0700
+++ b/go/import-archive.cc	Tue Apr 29 22:32:40 2014 -0400
@@ -261,7 +261,7 @@
   char size_string[size_string_size + 1];
   memcpy(size_string, hdr->ar_size, size_string_size);
   char* ps = size_string + size_string_size;
-  while (ps[-1] == ' ')
+  while (ps > size_string && ps[-1] == ' ')
     --ps;
   *ps = '\0';
 

Reply via email to