edrdos icon indicating copy to clipboard operation
edrdos copied to clipboard

INT21,36 handler scales numers wrong

Open boeckmann opened this issue 11 months ago • 2 comments

Affected file: drdos/disk.asm Routine: func36 Reference: https://fd.lod.bz/rbil/interrup/dos_kernel/2136.html

When operating on a drive with either more than 0xffff total clusters or 0xffff clusters free, the code tries to adapt the the values by shifting the cluster numbers to the right and shifting the sectors per cluster to the left. However, only the clusters free is taken into account and scaled, making the total clusters value wrong if a shift is made.

Also, it should be made sure that the values returned via AX*BC*CX and AX*CX*DX fit within 32 bits. This is because software calling this routine could calculate value with 32-bit arithmetic, and then would cause an overflow.

boeckmann avatar Jan 11 '25 10:01 boeckmann

First noticed in https://github.com/SvarDOS/edrdos/issues/128#issuecomment-2581291697

ecm-pushbx avatar Jan 11 '25 11:01 ecm-pushbx

Fixed partially by https://hg.pushbx.org/ecm/edrdos/rev/ec560d130824

The fitting within 32-bit arithmetic is not ensured by this if the bpc is >32 KiB to begin with (before the loop).

ecm-pushbx avatar Jan 11 '25 12:01 ecm-pushbx