From b901a125510486e190dd841dfa616cafff0c9242 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 22 May 2007 23:27:46 -0700 Subject: [PATCH] Make it safe to call close_file on an already closed file. The SYSLINUX internal API closes a file automatically upon reading to block EOF (not necessarily file EOF!) Thus, it's fairly likely we'll get SI == 0 (closed file) passed to close_file at some point or another. Just plain admit it, and make close_file accept SI == 0 by spec. --- comboot.inc | 3 --- extlinux.asm | 4 +++- getc.inc | 3 --- isolinux.asm | 4 +++- ldlinux.asm | 4 +++- pxelinux.asm | 4 +++- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/comboot.inc b/comboot.inc index 4896e39..034f924 100644 --- a/comboot.inc +++ b/comboot.inc @@ -434,10 +434,7 @@ comapi_read: ; comapi_close: mov si,P_SI - and si,si - jz .nothing call close_file -.nothing: clc ret diff --git a/extlinux.asm b/extlinux.asm index 7d73507..a590a36 100644 --- a/extlinux.asm +++ b/extlinux.asm @@ -1039,8 +1039,10 @@ ThisInode resb EXT2_GOOD_OLD_INODE_SIZE ; The most recently opened inode ; Assumes CS == DS. ; close_file: + and si,si + jz .closed mov dword [si],0 ; First dword == file_left - ret +.closed: ret ; ; searchdir: diff --git a/getc.inc b/getc.inc index 610d01b..5c8dc86 100644 --- a/getc.inc +++ b/getc.inc @@ -162,9 +162,6 @@ close: push si mov bx,[CurrentGetC] mov si,[bx+gc_file] - and si,si - jz .closed -.closed: call close_file add bx,getc_file_size mov [CurrentGetC],bx diff --git a/isolinux.asm b/isolinux.asm index de4f164..f9e8741 100644 --- a/isolinux.asm +++ b/isolinux.asm @@ -1143,8 +1143,10 @@ local_boot: ; Assumes CS == DS. ; close_file: + and si,si + jz .closed mov dword [si],0 ; First dword == file_left - ret +.closed: ret ; ; searchdir: diff --git a/ldlinux.asm b/ldlinux.asm index 7d7b8f2..eed2951 100644 --- a/ldlinux.asm +++ b/ldlinux.asm @@ -1065,8 +1065,10 @@ search_dos_dir: ; Assumes CS == DS. ; close_file: + and si,si + jz .closed mov dword [si],0 ; First dword == file_left - ret +.closed: ret ; ; searchdir: diff --git a/pxelinux.asm b/pxelinux.asm index 253aa0f..3e50245 100644 --- a/pxelinux.asm +++ b/pxelinux.asm @@ -1078,8 +1078,10 @@ memory_scan_for_pxenv_struct: ; side and send a courtesy ERROR packet to the server. ; close_file: + and si,si + jz .closed mov word [si],0 ; Not in use - ret +.closed: ret ; ; searchdir: -- 2.7.4