Skip to content

Commit

Permalink
[PATCH] vc: Use correct size on buffer copy in vc_resize
Browse files Browse the repository at this point in the history
In the unlikely case of the new screen width much wider then the old,
use (old_row_size * new_rows) instead of new_screen_size to prevent a
buffer overrun during the copy.

Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Antonino A. Daplas authored and Linus Torvalds committed Sep 15, 2005
1 parent 6d36ba6 commit 065d9ca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/char/vt.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,13 +810,14 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines)
* from the top and bottom of cursor position
*/
old_origin += (vc->vc_y - new_rows/2) * old_row_size;
end = old_origin + new_screen_size;
end = old_origin + (old_row_size * new_rows);
}
} else
/*
* Cursor near the top, copy contents from the top of buffer
*/
end = (old_rows > new_rows) ? old_origin + new_screen_size :
end = (old_rows > new_rows) ? old_origin +
(old_row_size * new_rows) :
vc->vc_scr_end;

update_attr(vc);
Expand Down

0 comments on commit 065d9ca

Please sign in to comment.