From:	AITGW::"goathunter@WKUVX1.BITNET" "Hunter Goatley, WKU" 12-MAR-1992 12:55:16.93
To:	getcmd-l@WKUVX1.BITNET
CC:	
Subj:	GETCMD 02-001 problem found---here's the patch....

Received: by AITGW.DECnet (utk-mail11 v1.5) ; Thu, 12 Mar 92 12:54:53 EST
Received: from ukcc.uky.edu by aitgw.ge.com (5.65/GE Gateway 1.5)
	id AA26170; Thu, 12 Mar 92 12:54:47 -0500
Received: from ukcc.uky.edu by UKCC.uky.edu (IBM VM SMTP V2R2)
   with BSMTP id 3920; Thu, 12 Mar 92 12:48:25 EST
Received: from UKCC by ukcc.uky.edu (Mailer R2.08) with BSMTP id 0171; Thu, 12
 Mar 92 12:48:15 EST
Received: from WKUVX1.BITNET by ukcc.uky.edu (Mailer R2.08) with BSMTP id 0090;
 Thu, 12 Mar 92 12:46:52 EST
Errors-To: goathunter@WKUVX1.BITNET
X-Listname: GETCMD Announcement List <GETCMD-L@WKUVX1.BITNET>
Received: by WKUVX1.BITNET (MX V3.0A) id 9797; Thu, 12 Mar 1992 11:20:05 CST
Sender: goathunter@WKUVX1.BITNET
Date: Thu, 12 Mar 1992 11:20:04 CST
From: "Hunter Goatley, WKU" <goathunter@WKUVX1.BITNET>
Reply-To: "Hunter Goatley, WKU" <goathunter@WKUVX1.BITNET>
To: getcmd-l@WKUVX1.BITNET
Message-Id: <0095777F.45F62940.9797@WKUVX1.BITNET>
Subject: GETCMD 02-001 problem found---here's the patch....
 
Thanks to Dave Barkelew, a rather severe problem was discovered in my
GETCMD program (version 02-001).  If you have POOLCHECK enabled, your
system *will* crash.  In essence, GETCMD incorrectly deallocates the
nonpaged pool containing the second AST.  If POOLCHECK is enabled, the
deallocated buffer is written over and the system crashes when control is
passed to it.
 
The problem *has* been solved.  There are two ways to go with this:
 
  1.  A patch is provided below to bring you to GETCMD 02-002.  Both
      UNIX-style context and SUMSLP patches are included.
 
  2.  A *new*, improved version of GETCMD (03-000) is available from
      my FILESERV.  This version is written in BLISS (with MACRO sources
      provided so everyone can build it) and is cleaner in many respects
      to the MACRO-32 version.  I strongly urge you to upgrade to the
      BLISS version.  To get it, send the following command in the body
      of a mail message to FILESERV@WKUVX1.BITNET
 
                SEND GETCMD
 
Sorry for any inconvenience this may have caused anyone, and thanks again
to Dave for finding the problem and being patient with me....
 
Hunter
------
Hunter Goatley, VMS Systems Programmer, Western Kentucky University
goathunter@WKUVX1.BITNET, 502-745-5251
 
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On 12-MAR-1992 11:08:38.98   By user GOATHUNTER (@WKUVX1.BITNET)
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. GETCMD-PATCH.TXT;1
$!       2. GETCMD.PATCH;1
$!       3. GETCMD.UPD;1
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
XThe files GETCMD.PATCH and GETCMD.UPD are patches that should be applied to
Xversion 02-001 of GETCMD.MAR.  The .PATCH file contains the UNIX-style
Xcontext diffs.  The .UPD file contains the SUMSLP commands necessary to patc
Vh
Xthe source.
X
XTo patch using the UNIX-style patch, set your default directory to the one
Xcontaining the GETCMD.MAR file and execute:
X
X`09$ unix_patch <getcmd.patch
X
XOf course, you should specify whatever command will invoke the UNIX-style
Xpatch program.
X
XIf you don't have the UNIX-style patch *and* you haven't modified the
XGETCMD.MAR source, you can apply the SUMSLP patch using the following comman
Vd:
X
X`09$ edit/sum getcmd.mar/update=getcmd.upd
X
XSorry for the inconvenience.
X
XHunter
X------
XHunter Goatley, VMS Systems Programmer, Western Kentucky University
Xgoathunter@WKUVX1.BITNET, 502-745-5251
$ CALL UNPACK GETCMD-PATCH.TXT;1 822367133
$ create 'f'
X*** getcmd.mar;1
X--- getcmd.mar
X**************
X*** 1,5
X  `09.TITLE`09GETCMD
X! `09.IDENT`09/02-001/
X  ;
X  ;  Copyright 1991 by Hunter Goatley.  This code may be freely distributed
X  ;  and modified for non-commercial purposes as long as this copyright noti
Vce
X--- 1,5 -----
X  `09.TITLE`09GETCMD
X! `09.IDENT`09/02-002/
X  ;
X  ;  Copyright `A9 1991--1992 by Hunter Goatley.  This code may be freely
X  ;  distributed and modified for non-commercial purposes as long as this
X**************
X*** 1,9
X  `09.TITLE`09GETCMD
X  `09.IDENT`09/02-001/
X  ;
X! ;  Copyright 1991 by Hunter Goatley.  This code may be freely distributed
X! ;  and modified for non-commercial purposes as long as this copyright noti
Vce
X! ;  is retained.
X  ;
X  ;++
X  ;
X--- 1,9 -----
X  `09.TITLE`09GETCMD
X  `09.IDENT`09/02-002/
X  ;
X! ;  Copyright `A9 1991--1992 by Hunter Goatley.  This code may be freely
X! ;  distributed and modified for non-commercial purposes as long as this
X! ;  copyright notice is retained.
X  ;
X  ;++
X  ;
X**************
X*** 25,30
X  ;
X  ;  Modified by:
X  ;
X  ;`0902-001`09`09Hunter Goatley`09`0927-SEP-1991 07:36
X  ;`09`09Modified poor-man's lockdown so it's correct.
X  ;
X--- 25,38 -----
X  ;
X  ;  Modified by:
X  ;
X+ ;`0902-002`09`09Hunter Goatley`09`0912-MAR-1992 10:09
X+ ;`09`09Fixed stupid mistake that caused systems to crash if
X+ ;`09`09POOLCHECK was enabled.  In the first AST routine, I was
X+ ;`09`09copying ACB_L_2ND_KAST to ACB$L_KAST to queue the 2nd
X+ ;`09`09AST to the original process.  After it was queued, I was
X+ ;`09`09using ACB$L_KAST as the address of the AST code to
X+ ;`09`09deallocate, incorrectly deallocating the 2nd KAST....
X+ ;
X  ;`0902-001`09`09Hunter Goatley`09`0927-SEP-1991 07:36
X  ;`09`09Modified poor-man's lockdown so it's correct.
X  ;
X**************
X*** 572,578
X  ;
X  ;  Queue the second AST back to original caller.
X  ;
X!  10$:`09MOVL`09ACB_L_2ND_KAST(R5),-`09`09; Set up ACB for other AST
X  `09`09ACB$L_KAST(R5)`09`09`09; ...
X  `09MOVL`09ACB_L_PID(R5),ACB$L_PID(R5)`09; Store originator's PID in ACB
X  `09BISB2`09#ACB$M_KAST,ACB$B_RMOD(R5)`09; Set Special KAST again
X--- 580,587 -----
X  ;
X  ;  Queue the second AST back to original caller.
X  ;
X!  10$:`09PUSHL`09ACB_L_KAST(R5)`09`09`09; Push our address onto stack
X! `09MOVL`09ACB_L_2ND_KAST(R5),-`09`09; Set up ACB for other AST
X  `09`09ACB$L_KAST(R5)`09`09`09; ...
X  `09MOVL`09ACB_L_PID(R5),ACB$L_PID(R5)`09; Store originator's PID in ACB
X  `09BISB2`09#ACB$M_KAST,ACB$B_RMOD(R5)`09; Set Special KAST again
X**************
X*** 604,610
X  ;  be the pool that contains this AST, but if the original process is dele
Vted,
X  ;  we need to delete the pool for the second AST and the ACB.
X  ;
X! `09PUSHL`09ACB$L_KAST(R5)`09`09`09; Save address of of this AST
X  `09TSTL`09ACB_L_KAST_STATUS(R5)`09`09; Did original process go away?
X  `09BNEQ`0930$`09`09`09`09; Branch if not
X  `09MOVL`09ACB_L_2ND_KAST(R5),R0`09`09; Get address of 2nd AST buffer
X--- 613,620 -----
X  ;  be the pool that contains this AST, but if the original process is dele
Vted,
X  ;  we need to delete the pool for the second AST and the ACB.
X  ;
X! ;  The address of this AST code has already been pushed onto the stack!!!!
X! ;
X  `09TSTL`09ACB_L_KAST_STATUS(R5)`09`09; Did original process go away?
X  `09BNEQ`0930$`09`09`09`09; Branch if not
X  `09MOVL`09ACB_L_2ND_KAST(R5),R0`09`09; Get address of 2nd AST buffer
$ CALL UNPACK GETCMD.PATCH;1 1836215306
$ create 'f'
X-    2,    6
X`09.IDENT`09/02-002/
X;
X;  Copyright `A9 1991--1992 by Hunter Goatley.  This code may be freely
X;  distributed and modified for non-commercial purposes as long as this
X;  copyright notice is retained.
X-   27
X;`0902-002`09`09Hunter Goatley`09`0912-MAR-1992 10:09
X;`09`09Fixed stupid mistake that caused systems to crash if
X;`09`09POOLCHECK was enabled.  In the first AST routine, I was
X;`09`09copying ACB_L_2ND_KAST to ACB$L_KAST to queue the 2nd
X;`09`09AST to the original process.  After it was queued, I was
X;`09`09using ACB$L_KAST as the address of the AST code to
X;`09`09deallocate, incorrectly deallocating the 2nd KAST....
X;
X-  575,  575
X 10$:`09PUSHL`09ACB$L_KAST(R5)`09`09`09; Push our address onto stack
X`09MOVL`09ACB_L_2ND_KAST(R5),-`09`09; Set up ACB for other AST
X-  607,  607
X;  The address of this AST code has already been pushed onto the stack!!!!
X;
X/
$ CALL UNPACK GETCMD.UPD;1 1062175386
$ v=f$verify(v)
$ EXIT
