]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: range-check 3rd argument of .align et al
authorJan Beulich <jbeulich@suse.com>
Fri, 16 May 2025 08:37:46 +0000 (10:37 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 16 May 2025 08:37:46 +0000 (10:37 +0200)
Negative values would have been silently converted to large positive
ones, which may not be the user's intention. Similarly overly large
values would have been silently truncated. Warn them instead, and zap
such values.

gas/read.c

index 31b89b7cbc8b92f8e06818154b870eb9a2f4cdf0..0b817b790a1470dfaa300b8958b93c2e6866712e 100644 (file)
@@ -1598,7 +1598,13 @@ s_align (signed int arg, int bytes_p)
       else
        {
          ++input_line_pointer;
-         max = get_absolute_expression ();
+         offsetT val = get_absolute_expression ();
+         max = val;
+         if (val < 0 || max != val)
+           {
+             as_warn (_("ignoring out of range alignment maximum"));
+             max = 0;
+           }
        }
     }