summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-02-27 16:17:23 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-02-27 16:17:23 -0800
commitb89d1480c656a4f4642cb84ed18d9214faca1308 (patch)
tree248e3cb35062f518635faede223ee5d178a9c487
parent173ac73758fde865cfb374d27411439629e09b75 (diff)
downloadsyslinux-3.70-pre2.tar.gz
Tighten close_file, fix SYSLINUX new file APIsyslinux-3.70-pre2
Define close_file slightly tighter: - It is permitted to call close_file with a zero filehandle - close_file zeros SI Fix the handling of the new API in SYSLINUX. It appears file_left was never actually initialized; it simply didn't matter since the old code would either trip on reaching the end of the FAT chain or count the data it needed. Now operating according to spec.
-rw-r--r--comboot.inc3
-rw-r--r--extlinux.asm1
-rw-r--r--isolinux.asm1
-rw-r--r--ldlinux.asm20
4 files changed, 17 insertions, 8 deletions
diff --git a/comboot.inc b/comboot.inc
index 99a41154..07ec352a 100644
--- a/comboot.inc
+++ b/comboot.inc
@@ -61,10 +61,7 @@
; 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
diff --git a/extlinux.asm b/extlinux.asm
index afcdb334..73c8bed5 100644
--- a/extlinux.asm
+++ b/extlinux.asm
@@ -1010,6 +1010,7 @@ close_file:
and si,si
jz .closed
mov dword [si],0 ; First dword == file_bytesleft
+ xor si,si
.closed: ret
;
diff --git a/isolinux.asm b/isolinux.asm
index cee100fe..42935645 100644
--- a/isolinux.asm
+++ b/isolinux.asm
@@ -1141,6 +1141,7 @@ close_file:
and si,si
jz .closed
mov dword [si],0 ; First dword == file_left
+ xor si,si
.closed: ret
;
diff --git a/ldlinux.asm b/ldlinux.asm
index 4df94b73..b12403eb 100644
--- a/ldlinux.asm
+++ b/ldlinux.asm
@@ -1034,7 +1034,8 @@ search_dos_dir:
close_file:
and si,si
jz .closed
- mov dword [si],0 ; First dword == file_left
+ mov dword [si],0 ; First dword == file_sector
+ xor si,si
.closed: ret
;
@@ -1092,6 +1093,11 @@ searchdir:
; SI and EAX are already set
mov [si+file_bytesleft],eax
+ push eax
+ add eax,SECTOR_SIZE-1
+ shr eax,SECTOR_SHIFT
+ mov [si+file_left],eax ; Sectors left
+ pop eax
and eax,eax ; EAX != 0
jz .badfile
ret ; Done!
@@ -1361,14 +1367,18 @@ getfssec:
call getfssec_edx
mov [si+file_sector],edx
pop ecx ; Sectors requested read
- pushf ; Save CF from getfssec_edx
shl ecx,SECTOR_SHIFT
cmp ecx,[si+file_bytesleft]
- jna .noteof
+ ja .eof
+.noteof:
+ sub [si+file_bytesleft],ecx ; CF <- 0
+ pop edx
+ ret
+.eof:
mov ecx,[si+file_bytesleft]
-.noteof: sub ecx,[si+file_bytesleft]
- popf
+ call close_file
pop edx
+ stc
ret
;