PR binutils/19935
[deliverable/binutils-gdb.git] / ld / deffilep.y
index 9121f8f59c3fa9a477f2a2d84dfb7e9cded5f3ed..ccceed04997ca567f46ac4e4800a6a9a98db2318 100644 (file)
@@ -1,7 +1,6 @@
 %{ /* deffilep.y - parser for .def files */
 
-/*   Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
-     2007, 2009 Free Software Foundation, Inc.
+/*   Copyright (C) 1995-2017 Free Software Foundation, Inc.
 
      This file is part of GNU Binutils.
 
@@ -905,8 +904,8 @@ def_file_add_directive (def_file *my_def, const char *param, int len)
       /* Scan forward until we encounter any of:
           - the end of the buffer
          - the start of a new option
-         - a newline seperating options
-          - a NUL seperating options.  */
+         - a newline separating options
+          - a NUL separating options.  */
       for (tend = (char *) (param + 1);
           (tend < pend
            && !(ISSPACE (tend[-1]) && *tend == '-')
@@ -934,13 +933,20 @@ def_file_add_directive (def_file *my_def, const char *param, int len)
 
       if (!diropts[i].param)
        {
-         char saved;
+         if (tend < pend)
+           {
+             char saved;
 
-         saved = * tend;
-         * tend = 0;
-         /* xgettext:c-format */
-         einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
-         * tend = saved;
+             saved = * tend;
+             * tend = 0;
+             /* xgettext:c-format */
+             einfo (_("Warning: .drectve `%s' unrecognized\n"), param);
+             * tend = saved;
+           }
+         else
+           {
+             einfo (_("Warning: corrupt .drectve at end of def file\n"));
+           }
        }
 
       lex_parse_string = 0;
This page took 0.024315 seconds and 4 git commands to generate.