libimg: check raw pnm payload size (broken files)

git-svn-id: svn://kolibrios.org@4229 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Ivan Baravy 2013-11-14 11:12:21 +00:00
parent 96c7d6c310
commit 0a44c9a5ca

View File

@ -158,6 +158,18 @@ endl
.header_parsed:
cmp [data_type], PNM_RAW
jne @f
mov ecx, [width]
imul ecx, [height]
lea eax, [ecx*3]
mov edx, [_data]
add edx, [_length]
sub edx, esi
cmp eax, edx
ja .error
@@:
mov eax, [pnm_type]
cmp eax, PNM_PBM
je .pbm
@ -172,6 +184,11 @@ include 'pbm.asm'
include 'pgm.asm'
include 'ppm.asm'
.error:
popa
xor eax, eax
ret
.quit:
popa
mov eax, [retvalue]