From: system@alchemy.chem.utoronto.ca (System Admin (Mike Peterson))
Subject: Patch to DRAW 2.00 (corrects "segmentation faults")
Organization: University of Toronto Chemistry Department
Date: Sat, 11 Apr 1992 17:40:25 GMT

Here is a patch to DRAW (Version 2.00, which we obtained from QCPE)
which will correct a problem where an array will overflow its bounds,
possibly corrupting other data in the program, or causing the program
to abort with a "segmentation fault" (on UNIX systems). This problem
may occur when more than 21 total atoms are used with MAXHEV=MAXLIT=40,
though it took more than 60 total atoms before the program failed
completely. I have also included a couple of updates so DRAW reads
MOPAC 6.0 output files more completely; these are not critical to
making DRAW work properly with large molecules.

This patch has been "approved" by Dr. J.J.P. Stewart, the author of
DRAW.

Here is a context diff for the 'reader.f' routine:

*** draw/src/reader.f.orig	Mon Nov 13 20:04:55 1989
--- draw/src/reader.f	Sat Mar 28 14:25:33 1992
***************
*** 15,23 ****
  C
        IMPLICIT REAL (A-H,O-Z)
        INCLUDE 'SIZES.CMN'
        REAL FVECT, VIBVEC, CVECT, CBETA
        INTEGER OFFSET
!       DIMENSION RIJ(3,NUMATM), FVECT(3*NUMATM, 3*NUMATM), NAT( NUMATM),
       .          NA( NUMATM) , NB( NUMATM), NC( NUMATM), GEO( 3, NUMATM),
       .          VIBVEC(3*NUMATM, 3*NUMATM), CVECT(1000), CBETA(1000), 
       .          BONDS( MPACK ), IA( NUMATM), IB( NUMATM), IC(NUMATM)
--- 15,26 ----
  C
        IMPLICIT REAL (A-H,O-Z)
        INCLUDE 'SIZES.CMN'
+ c     Following line added to correct dimension of array RIJ.
+       PARAMETER (MAXRIJ=NUMATM*(NUMATM+1)/2)
        REAL FVECT, VIBVEC, CVECT, CBETA
        INTEGER OFFSET
! c     Following line modified to correct dimension of array RIJ.
!       DIMENSION RIJ(MAXRIJ), FVECT(3*NUMATM, 3*NUMATM), NAT( NUMATM),
       .          NA( NUMATM) , NB( NUMATM), NC( NUMATM), GEO( 3, NUMATM),
       .          VIBVEC(3*NUMATM, 3*NUMATM), CVECT(1000), CBETA(1000), 
       .          BONDS( MPACK ), IA( NUMATM), IB( NUMATM), IC(NUMATM)
***************
*** 69,76 ****
        DATA DATUM/'PHA ELE','TA  ELE','RADIENT','HEAT:  ','VERSION',
       +           'NAL HEA','NIC ENE','ORE REP','ION POT','ION TIM',
       +           'SCF CAL',' <SZ>  ',' <S**2>',' OF SIN','AT OF F',
!      +           'BLY OCC', 'LED LEV', 'LAR WEI', 'ERO POI',
!      +           11*'XXXXXXX'/
        DATA SMALL/'IST ANG','IAN COO','NAL GEO','0DIPOLE','RON POP',
       +           'GENVALU','OLE CON','TER DEP', 22*'XXXXXXX'/
        DATA LARGE/'NTERATOMIC DIS','ALPHA EIGENVEC',
--- 72,79 ----
        DATA DATUM/'PHA ELE','TA  ELE','RADIENT','HEAT:  ','VERSION',
       +           'NAL HEA','NIC ENE','ORE REP','ION POT','ION TIM',
       +           'SCF CAL',' <SZ>  ',' <S**2>',' OF SIN','AT OF F',
!      +           'BLY OCC','LED LEV','LAR WEI','ERO POI','TAL ENE',
!      +           10*'XXXXXXX'/
        DATA SMALL/'IST ANG','IAN COO','NAL GEO','0DIPOLE','RON POP',
       +           'GENVALU','OLE CON','TER DEP', 22*'XXXXXXX'/
        DATA LARGE/'NTERATOMIC DIS','ALPHA EIGENVEC',
***************
*** 95,101 ****
        NCLOSE = 0
        NOPEN = 0
        NATOMS = 0
!       RIJ( 1, 1) = 0
        FVECT(1,1) = 0
        VIBVEC(1,1) = 0
        CVECT(1) = 0
--- 98,105 ----
        NCLOSE = 0
        NOPEN = 0
        NATOMS = 0
! c     Following line omitted due to change in RIJ dimensions.
! c     RIJ( 1, 1) = 0
        FVECT(1,1) = 0
        VIBVEC(1,1) = 0
        CVECT(1) = 0
***************
*** 420,425 ****
--- 424,430 ----
        NELECS=NCLOSE*2+NOPEN+NALPHA+NBETA
        IF(I.EQ.18)WEIGHT = VALD( 18)
        IF(I.EQ.19)ZPE = VALD( 19)
+       IF(I.EQ.20)TOTALE = VALD( 20)
        NEWDAT = .TRUE.
        GOTO 1000
    310 CONTINUE
***************
*** 574,579 ****
--- 579,585 ----
  *  ELECTRON POPULATIONS READ IN
  *
        IF (DEBUGI) CALL DEBUGR('READER: READING ELECTRON POPULATIONS.')
+       READ(IR,'(A)',END=999,ERR=999) DUMC
        DO 365 ITEMP = 1, NORBS/8
           READ(IR,'(A)',END=999,ERR=999) LINE
   365  CONTINUE

Mike.
-- 
What are the chances that any computer system will ever "work" properly?
... and Slim just left town. -*- Mike Peterson, SysAdmin, U/Toronto Chemistry