Skip to contentSkip to conversation

vc: Use correct size on buffer copy in vc_resize

PATCH New Antonino A. Daplas 1 participant 1 message Sep 15, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 3/3 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.

---
 vt.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/char/vt.c +3 -2
@@ -810,13 +810,14 @@ int vc_resize(struct vc_data *vc, unsign
 			 * 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);

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php