Commit 065d9cac authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

[PATCH] vc: Use correct size on buffer copy in vc_resize

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: default avatarAntonino Daplas <adaplas@pol.net>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6d36ba62
...@@ -810,13 +810,14 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int lines) ...@@ -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 * from the top and bottom of cursor position
*/ */
old_origin += (vc->vc_y - new_rows/2) * old_row_size; 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 } else
/* /*
* Cursor near the top, copy contents from the top of buffer * 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; vc->vc_scr_end;
update_attr(vc); update_attr(vc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment