fix typo
[deliverable/binutils-gdb.git] / gas / read.c
index a22c7505efebe4bb108e43118be9c7d1e616c541..9d35766a6a93142095ee3737ab47b47dd44d09c0 100644 (file)
@@ -2136,7 +2136,7 @@ s_errwarn (int err)
      self-contained message, one that can be passed like the
      demand_copy_C_string return value, and with no assumption on the
      location of the name of the directive within the message.  */
-  char *msg
+  const char *msg
     = (err ? _(".error directive invoked in source file")
        : _(".warning directive invoked in source file"));
 
@@ -3255,7 +3255,9 @@ assign_symbol (char *name, int mode)
          && !S_CAN_BE_REDEFINED (symbolP))
        {
          as_bad (_("symbol `%s' is already defined"), name);
-         symbolP = symbol_clone (symbolP, 0);
+         ignore_rest_of_line ();
+         input_line_pointer--;
+         return;
        }
       /* If the symbol is volatile, copy the symbol and replace the
         original with the copy, so that previous uses of the symbol will
@@ -3392,11 +3394,20 @@ s_space (int mult)
        {
          offsetT i;
 
-         if (mult == 0)
-           mult = 1;
-         bytes = mult * exp.X_add_number;
-         for (i = 0; i < exp.X_add_number; i++)
-           emit_expr (&val, mult);
+         /* PR 20901: Check for excessive values.
+            FIXME: 1<<10 is an arbitrary limit.  Maybe use maxpagesize instead ?  */
+         if (exp.X_add_number < 0 || exp.X_add_number > (1 << 10))
+           as_bad (_("size value for space directive too large: %lx"),
+                   (long) exp.X_add_number);
+         else
+           {
+             if (mult == 0)
+               mult = 1;
+             bytes = mult * exp.X_add_number;
+
+             for (i = 0; i < exp.X_add_number; i++)
+               emit_expr (&val, mult);
+           }
        }
     }
   else
@@ -3541,7 +3552,7 @@ s_float_space (int float_type)
     }
   else
     {
-      char *err;
+      const char *err;
 
       err = md_atof (float_type, temp, &flen);
       know (flen <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
@@ -4083,14 +4094,14 @@ s_reloc (int ignore ATTRIBUTE_UNUSED)
     case O_constant:
       exp.X_add_symbol = section_symbol (now_seg);
       exp.X_op = O_symbol;
-      /* Fall thru */
+      /* Fallthru */
     case O_symbol:
       if (exp.X_add_number == 0)
        {
          reloc->u.a.offset_sym = exp.X_add_symbol;
          break;
        }
-      /* Fall thru */
+      /* Fallthru */
     default:
       reloc->u.a.offset_sym = make_expr_symbol (&exp);
       break;
@@ -4593,9 +4604,7 @@ emit_expr_fix (expressionS *exp, unsigned int nbytes, fragS *frag, char *p,
    BITFIELD_CONS_EXPRESSIONS.  */
 
 static void
-parse_bitfield_cons (exp, nbytes)
-     expressionS *exp;
-     unsigned int nbytes;
+parse_bitfield_cons (expressionS *exp, unsigned int nbytes)
 {
   unsigned int bits_available = BITS_PER_CHAR * nbytes;
   char *hold = input_line_pointer;
@@ -4780,9 +4789,7 @@ parse_mri_cons (expressionS *exp, unsigned int nbytes)
    To use this for a target, define REPEAT_CONS_EXPRESSIONS.  */
 
 static void
-parse_repeat_cons (exp, nbytes)
-     expressionS *exp;
-     unsigned int nbytes;
+parse_repeat_cons (expressionS *exp, unsigned int nbytes)
 {
   expressionS count;
   int i;
@@ -4924,7 +4931,7 @@ float_cons (/* Clobbers input_line-pointer, checks end-of-line.  */
 {
   char *p;
   int length;                  /* Number of chars in an object.  */
-  char *err;           /* Error from scanning floating literal.  */
+  const char *err;             /* Error from scanning floating literal.  */
   char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
 
   if (is_it_end_of_statement ())
@@ -5535,6 +5542,12 @@ next_char_of_string (void)
   c = *input_line_pointer++ & CHAR_MASK;
   switch (c)
     {
+    case 0:
+      /* PR 20902: Do not advance past the end of the buffer.  */
+      -- input_line_pointer;
+      c = NOT_A_CHAR;
+      break;
+
     case '\"':
       c = NOT_A_CHAR;
       break;
@@ -5631,6 +5644,12 @@ next_char_of_string (void)
          bump_line_counters ();
          break;
 
+       case 0:
+         /* Do not advance past the end of the buffer.  */
+         -- input_line_pointer;
+         c = NOT_A_CHAR;
+         break;
+
        default:
 
 #ifdef ONLY_STANDARD_ESCAPES
This page took 0.024817 seconds and 4 git commands to generate.