Picked from the commit at fe1c4dc7fe
The referenced issue is at https://github.com/dosemu2/fdpp/issues/212
The patch was applied using unix2dos on the patch file
then `patch -p1 --binary` with the patch file as stdin.
The original used a new define for the maximum path length.
As there is no difference to our current SFTMAX define I
changed this hunk to retain the SFTMAX use.
This fixes a bug when eg function 3Dh receives a buffer
that starts with ".\" but the byte in memory before this
buffer happens to be also a dot. I ran into this problem
semi-randomly during building EDR-DOS with the most recent
WarpLink build. If WarpLink was placed somewhat low in the
Low Memory Area then one of its function 3Dh calls would
happen to have a dot before the pathname buffer. (I had to
load lCDebug using the last fit strategy then enter TSR mode,
to catch the bug without the presence of the debugger working
around the occurrence of the bug.)
Original commit Metadata:
From: Stas Sergeev <stsp@users.sourceforge.net>
Date: Wed, 1 Feb 2023 13:01:55 +0500
Subject: [PATCH] truename: fix array overrun [fixes#212]
src[-2] was peeking into a random memory location.
It seems entire truename() is written by some morons... :(
Its completely unreadable and full of bugs.
lDebug wants to access the environment while executing
as a device driver. Instead of building it in a variable
then copying it to 68h:0 after FDCONFIG.SYS processing,
just build it there to begin with.
To be able to return free space on larger non local disks, the redirector
needs an extension. Dosemu2 has implemented this function and FDPP
has an almost identical patch to this. If the extension is not
implemented by your chosen redirector, then fallback to the standard
110c function is done for int21/7303.
With this patch up to 2TB (with Dosemu2 reporting in 512 blocks) can be
displayed.
Also checks that the total amount of clusters is possible
for the detected file system, erroring out otherwise.
Small FAT32 is displayed in the verbose output specifically.
This should be Enhanced DR-DOS compatible.
oemboot.asm contains an optimisation to save 2 bytes,
by using mov instead of a lea with bp evaluating to
a constant value. This was needed to fit the addition
for 256 spc support. It is otherwise unrelated.
The LBA detection patch offsets in SYS have also been
updated to match the changed boot.asm offsets.
This should be compatible to Enhanced DR-DOS.
Tested by building a boot image like the following:
nasm ../ldosmbr/oldmbr.asm -o oldmbr.bin
nasm ../ldosboot/boot.asm -D_FAT16=1 -I ../lmacros/ \
-D_LOAD_NAME="'LDEBUG'" -o boot16.bin
nasm bootimg.asm -I ../lmacros/ -o disk16.img \
-D_MBR -D_ALIGNDATA -D_BOOTPATCHFILE=boot16.bin \
-D_MBRPATCHFILE=oldmbr.bin -D_BPE=16 \
-D_SPI='(_SPC * 5000)' -D_NUMROOT=512 -D_SPC=256 \
-D_SPF='((_SPI / _SPC + 255) / 256)' \
-D_PAYLOADFILE=../ldebug/bin/ldebug.com,quit.com,\
::rename,../k256spc/bin/kernel.sys,kernel.sys,\
command.com,::fill,1,32,autoexec.bat
The repos bootimg, ldosboot, ldosmbr, and lmacros are
available at https://hg.pushbx.org/ecm/
The file ldebug.com is a recent bootable lDebug debugger.
The file command.com is a recent FreeCOM. The file quit.com
is assembled with NASM from
https://hg.pushbx.org/ecm/ldebug/file/e6035c05670a/misc/quit.asm
Run like this:
qemu-system-i386 -hda disk16.img -boot order=c -display curses
To the lDebug prompt "-" enter "boot protocol freedos",
then a "q" command. On success, the quit.com command
can be run to quit the qemu VM.
Not yet done:
- initdisk.c:512 uses MAXCLUSTSIZE defined to 128. This is
not difficult to change but it is unclear whether this
should be changed.
- The boot loaders are not yet adjuscted, requiring use of
the ldosboot or lDebug loaders instead.
- A patch for FORMAT (copylefted) version 0.91u is available
from the Enhanced DR-DOS project. Mirrored in the directory at
https://pushbx.org/ecm/download/edrdos/freedos/
This should be easy enough to update to the most recent version.
The int86 function is used to call interrupt 21h
service 32h in the reset_drive function. This
function returns a pointer using the ds register.
ds will usually point into the DOS data segment
then (for our kernel). However, the compiler
assumed ds to be unchanged.
cast array using pointer to first element [newboot] instead of pointer to whole array [&newboot] to avoid OW error W115 "&array may not produce intended result" since the address of operator "&" is not required for getting the address of an array.