]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas/macro.c getstring
authorAlan Modra <amodra@gmail.com>
Thu, 9 Oct 2025 04:16:39 +0000 (14:46 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 9 Oct 2025 05:34:06 +0000 (16:04 +1030)
commit937aa6a37d23b6fd24150824a003abaeaef87910
treefdc8d9e1794d0c57b25bc58abb5fbdd7e9e0c4e5
parent7b67c40b51b36aea807261018ffb7b24065d5619
gas/macro.c getstring

This code:
      if (in->ptr[idx] == '!')
{
  idx++;
  sb_add_char (acc, in->ptr[idx++]);
}
and similar code in the other loop, blindly accessed the next element
of the string buffer without first checking idx against in->len,
leading to uninitialised accesses or buffer overruns.  Fix that, and
tidy the loops so that the function always returns the index one past
the last char consumed.  (It could return idx == in->len + 1).

* macro.c (getstring): Don't access past end of input string
buffer.  Tidy loops.  Don't return an index past in->len.
gas/macro.c