projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
424f384
)
ascii: Avoid buffer overread outputting page longer than allocated lines.
author
Ben Pfaff
<blp@cs.stanford.edu>
Fri, 11 Oct 2019 04:32:31 +0000
(
04:32
+0000)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Wed, 30 Oct 2019 22:41:21 +0000
(22:41 +0000)
This does seem like an odd case but I triggered it at one point and it
costs little to check for it.
src/output/ascii.c
patch
|
blob
|
history
diff --git
a/src/output/ascii.c
b/src/output/ascii.c
index 46e017c01e060e8dd9e051124caee906476988c2..1a470d0f53ee319e424634190e2a33bdb00967bb 100644
(file)
--- a/
src/output/ascii.c
+++ b/
src/output/ascii.c
@@
-415,14
+415,16
@@
ascii_output_lines (struct ascii_driver *a, size_t n_lines)
{
for (size_t y = 0; y < n_lines; y++)
{
- struct u8_line *line = &a->lines[y];
+ if (y < a->allocated_lines)
+ {
+ struct u8_line *line = &a->lines[y];
- while (ds_chomp_byte (&line->s, ' '))
- continue;
- fwrite (ds_data (&line->s), 1, ds_length (&line->s), a->file);
+ while (ds_chomp_byte (&line->s, ' '))
+ continue;
+ fwrite (ds_data (&line->s), 1, ds_length (&line->s), a->file);
+ u8_line_clear (&a->lines[y]);
+ }
putc ('\n', a->file);
-
- u8_line_clear (&a->lines[y]);
}
}