diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2023-03-28 16:37:41 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2023-03-30 14:13:19 +0000 |
| commit | 981e4b77cb96ab277ea3b7a1e8aebf0e4589c032 (patch) | |
| tree | 859be395622680d29b7fd878a93cb79dec043e77 /terminal.h | |
| parent | render: protect against integer underflow when calculating scroll area (diff) | |
term: protect against integer overflow when accumulating scroll damage
When accumulating scroll damage, we check if the last scroll damage’s
scrolling region, and type, matches the new/current scroll damage. If
so, the number of lines in the last scroll damage is increased,
instead of adding a new scroll damage instance to the list.
If the scroll damage list isn’t consumed, this build up of scroll
damage would eventually overflow.
And, even if it didn’t overflow, it could become large enough, that
when later used to calculate e.g. the affected surface area, while
rendering a frame, would cause an overflow there instead.
This patch fixes both issues by:
a) do an overflow check before increasing the line count
b) limit the line count to UINT16_MAX
Diffstat (limited to 'terminal.h')
| -rw-r--r-- | terminal.h | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -96,7 +96,7 @@ enum damage_type {DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE, struct damage { enum damage_type type; struct scroll_region region; - int lines; + uint16_t lines; }; struct row_uri_range { |
