diff options
author | Alan Modra <amodra@gmail.com> | 2020-12-15 21:54:09 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-12-16 01:13:58 +1030 |
commit | 7bed846687589e1346626e8bc9f2948340ef454b (patch) | |
tree | 4b656167da9efec90ae7711faf78e32f36762099 /gas/listing.c | |
parent | 9f132af9e189a6c1e90b1ab7ed84c6613c8ac596 (diff) | |
download | gdb-7bed846687589e1346626e8bc9f2948340ef454b.zip gdb-7bed846687589e1346626e8bc9f2948340ef454b.tar.gz gdb-7bed846687589e1346626e8bc9f2948340ef454b.tar.bz2 |
PR27071, gas bugs uncovered by fuzzing
PR 27071
* config/obj-elf.c (elf_obj_symbol_clone_hook): New function.
(elf_format_ops): Set symbol_clone_hook.
* config/obj-elf.h (elf_obj_symbol_clone_hook): Declare.
(obj_symbol_clone_hook): Define.
* listing.c (buffer_line): Avoid integer overflow on paper_width
set to zero.
Diffstat (limited to 'gas/listing.c')
-rw-r--r-- | gas/listing.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/gas/listing.c b/gas/listing.c index 359dc09..bf38c1a 100644 --- a/gas/listing.c +++ b/gas/listing.c @@ -508,17 +508,12 @@ buffer_line (file_info_type *file, char *line, unsigned int size) fseek (last_open_file, file->pos, SEEK_SET); } - /* Leave room for null. */ - size -= 1; - c = fgetc (last_open_file); while (c != EOF && c != '\n' && c != '\r') { - if (count < size) + if (++count < size) *p++ = c; - count++; - c = fgetc (last_open_file); } @@ -536,7 +531,7 @@ buffer_line (file_info_type *file, char *line, unsigned int size) if (c == EOF) { file->at_end = 1; - if (count + 2 < size) + if (count + 3 < size) { *p++ = '.'; *p++ = '.'; |