compiler: Don't overwrite memory if an archive has a bad file name.
authorIan Lance Taylor <ian@gcc.gnu.org>
Wed, 30 Apr 2014 02:38:30 +0000 (02:38 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 30 Apr 2014 02:38:30 +0000 (02:38 +0000)
From-SVN: r209924

gcc/go/gofrontend/import-archive.cc

index 9a1d5b3d7ef61bde7aef96fd2bbdbe4bd0eb47fa..34fb528ab5c6232f487462400af52d7e25ffe0bd 100644 (file)
@@ -261,7 +261,7 @@ Archive_file::interpret_header(const Archive_header* hdr, off_t off,
   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';