Skip to content

Commit 4e43287

Browse files
committed
prevent files becoming larger than 2^32-1 bytes
1 parent 981d016 commit 4e43287

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

drdos/bdevio.asm

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,19 @@ ifdef FATPLUS
834834
mov ax,byteoff+6
835835
adc ax,0
836836
mov fsize+6,ax
837+
else
838+
jnc fdw_e03 ; file size + fdrwcnt <4GB?
839+
mov ax,fsize ; otherwise restrict fdrwcnt
840+
sbb fdrwcnt,ax
841+
jnz fdw_e02 ; can write at least a single byte?
842+
mov ax,ED_ACCESS ; if not return access denied
843+
jmp fdos_error
844+
fdw_e02:
845+
xor ax,ax
846+
dec ax
847+
mov fsize,ax
848+
mov fsize+2,ax
849+
fdw_e03:
837850
endif
838851
; div clsize ; AX whole blocks required
839852
; push dx

0 commit comments

Comments
 (0)