comboot.inc: update test for oversized files
authorH. Peter Anvin <hpa@zytor.com>
Wed, 27 Feb 2008 20:56:20 +0000 (12:56 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 27 Feb 2008 20:59:59 +0000 (12:59 -0800)
The test for oversized COMBOOT files have to be updated to be an a
posteori test, since the length might not be known a priori.

comboot.inc

index 646f44d..3a3c306 100644 (file)
 
 ; Looks like a COMBOOT image but too large
 comboot_too_large:
+               and si,si
+               jnz .closed
+               call close_file
+.closed:
                mov si,err_comlarge
                call cwritestr
                jmp enter_command
@@ -71,9 +75,6 @@ comboot_too_large:
 ; do, however, allow the execution of INT 20h to return to SYSLINUX.
 ;
 is_comboot_image:
-               cmp eax,0ff00h          ; Max size in bytes
-               jae comboot_too_large
-
                push si                 ; Save file handle
 
                call make_plain_cmdline
@@ -124,9 +125,11 @@ is_comboot_image:
                ; Now actually load the file...
                pop si                  ; File handle
                mov bx,100h             ; Load at <seg>:0100h
-               mov cx,0FF00h >> SECTOR_SHIFT
+               mov cx,10000h >> SECTOR_SHIFT
                                        ; Absolute maximum # of sectors
                call getfssec
+               cmp ecx,0FF00h          ; Maximum size
+               jae comboot_too_large
 
                ; And invoke the program...
                mov ax,es