video: improve boundary checking

Add checks to fill_rect() and video_scroll().

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>

git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@871 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Blue Swirl
2010-09-29 18:34:41 +00:00
parent 6cc8774764
commit 9db24694ca

View File

@@ -142,7 +142,8 @@ fill_rect( int col_ind, int x, int y, int w, int h )
char *pp; char *pp;
unsigned long col = get_color(col_ind); unsigned long col = get_color(col_ind);
if( !video.has_video || x < 0 || y < 0 || x+w > video.fb.w || y+h > video.fb.h ) if (!video.has_video || x < 0 || y < 0 || w <= 0 || h <= 0 ||
x + w > video.fb.w || y + h > video.fb.h)
return; return;
pp = (char*)video.fb.mphys + video.fb.rb * y; pp = (char*)video.fb.mphys + video.fb.rb * y;
@@ -203,6 +204,9 @@ video_scroll( int height )
{ {
int i, offs, size, *dest, *src; int i, offs, size, *dest, *src;
if (height <= 0 || height >= video.fb.h) {
return;
}
offs = video.fb.rb * height; offs = video.fb.rb * height;
size = (video.fb.h * video.fb.rb - offs)/16; size = (video.fb.h * video.fb.rb - offs)/16;
dest = (int*)video.fb.mphys; dest = (int*)video.fb.mphys;