Tracker: Bugs

5 "CALL 5" entry broken; will crash system - ID: 2421577
Last Update: Comment added ( perditionc )

The "CALL 5" CP/M compatibility entry crashes when called. It doesn't adjust the stack properly. If it did, it would also branch on the wrong function numbers.

Attached diff merges in some code I've written for an upcoming RxDOS release (also GNU GPL, so you can remove the additional notice in the diff).

Note that a better solution may be to write the string A9h,F0h,FEh,CDh,20h at address 5 of each PSP. These bytes are the opcodes "test ax, FEF0h" and "int 20h", terminating all programs that try to "call 5". The useless test opcode allows the data at address 6 of the PSP to remain valid (even though that's just more CP/M compatibility crap). The upcoming RxDOS release will include a "compile"-time option that adds this into the PSP copy/create code and removes all other "CALL 5" code.

On a side note, I've relocated RxDOS's "CALL 5" entry into the section called HMA_TEXT for DOS-C (DOSCODE for RxDOS) as well.


Where the former DOS-C approach failed:

> ; Stack is:
> ; return offset
> ; psp seg
> ; 000ah
> ;
> push bp ; trash old return address
> mov bp,sp
> xchg bp,[2+bp]
> pop bp

Additionally "trashing" (overwriting with bp) the useless value of 000Ah is not required for anything.

> pushf ; start setting up int 21h stack
> ;
> ; now stack is
> ; return offset
> ; psp seg
> ; flags

The above "trashing" code didn't remove the useless value from the stack.

> cmp cl,024h
> jbe cpm_error

Should branch to cpm_error on values >24h, 00h-24h are allowed.


C. Masloch ( estron ) - 2008-12-12 07:48:54 PST

5

Closed

Fixed

Kenneth Davis

Kernel

None

Public


Comments ( 2 )

Date: 2010-07-30 03:30:35 PDT
Sender: perditionc

this should be fixed, if there are still any issues please re-open or post
a new bug.


Date: 2009-05-13 13:46:46 PDT
Sender: nobody


Hi :-) There is a much easier patch:

Replace "jbe cpm_error" with "ja cpm_error" in the original code :-)

http://freedos.svn.sourceforge.net/viewvc/freedos/kernel/trunk/kernel/entry.asm?r1=1375&r2=1337&sortby=date

Eric




Attached File ( 1 )

Filename Description Download
entry.dif diff for DOS-C 2038/SVN entry.asm Download

Changes ( 7 )

Field Old Value Date By
category_id None 2010-07-30 03:30:35 PDT perditionc
status_id Open 2010-07-30 03:30:35 PDT perditionc
resolution_id None 2010-07-30 03:30:35 PDT perditionc
close_date - 2010-07-30 03:30:35 PDT perditionc
assigned_to nobody 2010-07-30 03:30:35 PDT perditionc
allow_comments 1 2010-07-30 03:30:35 PDT perditionc
File Added 305066: entry.dif 2008-12-12 07:48:54 PST estron