fix background buffer overrun

git-svn-id: svn://kolibrios.org@875 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-10-10 12:08:40 +00:00
parent b94939c0dc
commit 3a8ae3d4cb

View File

@ -2277,15 +2277,21 @@ sys_background:
cmp ebx,2 ; SET PIXEL cmp ebx,2 ; SET PIXEL
jnz nosb2 jnz nosb2
cmp ecx,[mem_BACKGROUND]
jae nosb2 mov ebx, [mem_BACKGROUND]
add ebx, 4095
and ebx, -4096
sub ebx, 4
cmp ecx, ebx
ja @F
mov eax,[img_background] mov eax,[img_background]
mov ebx,[eax+ecx] mov ebx,[eax+ecx]
and ebx,0xFF000000 ;255*256*256*256 and ebx,0xFF000000 ;255*256*256*256
and edx,0x00FFFFFF ;255*256*256+255*256+255 and edx,0x00FFFFFF ;255*256*256+255*256+255
add edx,ebx add edx,ebx
mov [eax+ecx],edx mov [eax+ecx],edx
; mov [bgrchanged],1 @@:
ret ret
nosb2: nosb2:
@ -2431,19 +2437,25 @@ sys_getbackground:
mov ax,[BgrDataHeight] mov ax,[BgrDataHeight]
mov [esp+36],eax mov [esp+36],eax
ret ret
nogb1: nogb1:
cmp eax,2 ; PIXEL cmp eax,2 ; PIXEL
jnz nogb2 jnz nogb2
; mov edx,0x160000-16
; cmp edx,ebx mov ecx, [mem_BACKGROUND]
; jbe nogb2 add ecx, 4095
; mov eax, [ebx+IMG_BACKGROUND] and ecx, -4096
sub ecx, 4
cmp ebx, ecx
ja @F
mov eax,[img_background] mov eax,[img_background]
mov eax,[ebx+eax] mov eax,[ebx+eax]
and eax, 0xFFFFFF and eax, 0xFFFFFF
mov [esp+36],eax mov [esp+36],eax
@@:
ret ret
nogb2: nogb2: