home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / ZCPR33 / Z3-33 / Z33FIX.001 < prev    next >
Text File  |  2000-06-30  |  4KB  |  92 lines

  1.                                ZCPR33 BUG FIX
  2.                                ==============
  3.  
  4. Fix Number:    001
  5. Date:        June 6, 1987
  6.  
  7.  
  8.       Resetting of the External Program Bit in the Command Status Flag
  9.  
  10.  
  11. The Problem
  12. -----------
  13.  
  14.      In the process of writing Programming Note #001, I realized that there
  15. is a weakness in the way the command processor handles the external program
  16. flag bit in the command status flag (CSF).  The command processor resets the
  17. bit only after the command line buffer has become empty.  Otherwise, it
  18. relies on error handlers to reset the bit.  New error handlers like Z33ERROR
  19. could be expected do this, but old error handlers, which do not know about
  20. this bit in the CSF, certainly cannot be expected to reset it.  Also,
  21. programs that set this bit before calling the parsing code in the command
  22. processor must remember to reset the bit before returning control to the
  23. command processor.  This situation leaves the command processor
  24. unnecessarily at the mercy of application programs.
  25.  
  26.      The shell bit in the CSF has the same problem, and shell programs must
  27. reset that bit (they generally reset the CSF to zero).  However, in the case
  28. of shells there is no way to avoid this situation.  As we shall see below, a
  29. single line of code in the command processor can deal with the problem of
  30. the external program bit.
  31.  
  32.  
  33. The Result
  34. ----------
  35.  
  36.      When the external program bit is left set and the next command line is
  37. processed, the parsing code will deal with incorrect passwords in a
  38. different way than when the bit is not set.  When the bit is not set, entry
  39. of an incorrect password causes the command processor to vector immediately
  40. to the error handler.  If the bit is set, the error handler is not invoked;
  41. only the bad directory flag in the file control block is set.  Programs that
  42. do not check the bad directory flag will simply act as though the referenced
  43. directory were the currently logged directory (i.e., just the way ZCPR30
  44. acted).  Thus, the consequences of this bug are not at all serious. 
  45. Moreover, the situation will rarely arise.  Here is an example command line,
  46. the one I used to verify the problem and the fix:
  47.  
  48.     A0:BASE>SAVE XX YY;WHL;XD PVT:;WHL SYSTEM
  49.  
  50. The SAVE command that runs here is the transient SAVE.COM.  When it detects
  51. the invalid numerical expression in the first token ('XX'), it sets the
  52. error bit, the ECP bit, and the external program bit, and returns to the
  53. command processor.  The command processor invokes the error handler.  If we
  54. tell the error handler to skip the save command and go on to the rest of the
  55. command line, the WHL command turns off the wheel byte (so that password
  56. checking will be turned on), and then the directory of a password-protected
  57. directory is requested.  Since the external program bit is still set from
  58. the SAVE command, if the wrong password is now entered, instead of invoking
  59. the error handler, the command processor will run XD, which will display the
  60. directory of A0 (not PVT).  Then last next command will set the wheel byte
  61. again.
  62.  
  63.  
  64. The Fix
  65. -------
  66.  
  67.      The fix is very simple.  Just before the label NEXTCMD1, which is the
  68. entry point for processing the error handling command line, we add one extra
  69. instruction to the preceding code:
  70.  
  71.     res    3,(hl)        ; Reset the external program bit
  72.  
  73. The code thus reads as follows:
  74.  
  75.     ld    hl,cmdstatfl    ; Point to the command status flag
  76.     ld    a,(hl)        ; Get a copy into register A
  77.     res    1,(hl)        ; Reset the actual error bit
  78.     res    2,(hl)        ; Reset the actual ECP bit
  79.     and    110b        ; Select ECP and error bits in original flag
  80.     cp    110b        ; Test for an ECP error
  81.     jp    z,error        ; Process ECP error with error handler
  82.     res    3,(hl)        ; Reset the external program bit
  83.  
  84. nextcmd1:
  85.     ld    sp,stack    ; Reset stack
  86.  
  87. It is important that the external program bit not be reset before the branch
  88. to the error handler, since the error processing code will use the
  89. information in this bit.  Similarly, it is important that it not be reset
  90. after NEXTCMD1, since the information in the bit will be used by the error
  91. handler, which is invoked at the NEXTCMD1 entry point in the code.
  92.