[comp.unix.xenix] An elm patch

samperi@mancol.UUCP (Dominick Samperi) (02/08/88)

After applying Chip Sulzenburg's SCO/Xenix patches to the source for
elm 1.7 beta, the resulting elm compiled and ran under Microport's
System V/AT (286 version)...almost. An attempt to send mail when the
sender's mailbox is emptry results in a segmentation violation. sdb
shows that the error occurs in the function create_readmsg_file(),
where a reference to header_table[current-1] is made, when current=0.
The patch below will make a small change to mailmsg2.c so that
create_readmsg_file() is called only when current > 0, and this seems
to have fixed the problem.

I guess the reason this bug does not show up on other systems is
that they do not catch the illegal array reference (or pointer
dereference).

Note: I have not studied the elm code in detail, so I cannot guarantee
that this fix will not have undesirable side effects, but I doubt that
it will.

Here is the patch, in the form of a context diff:

*** mailmsg2.c	Mon Feb  8 01:55:13 1988
--- ../mailmsg2.c	Mon Feb  8 01:54:35 1988
***************
*** 147,153
  
  	/** Edit the message **/
  
! 	if (edit_message)
  	  create_readmsg_file();	/* for "readmsg" routine */
  
  	ch = edit_message? 'e' : ' ';	/* drop through if needed... */

--- 147,153 -----
  
  	/** Edit the message **/
  
! 	if (edit_message && current > 0)
  	  create_readmsg_file();	/* for "readmsg" routine */
  
  	ch = edit_message? 'e' : ' ';	/* drop through if needed... */
-- 
Dominick Samperi, Manhattan College, NYC
	manhat!samperi@NYU.EDU  
	ihnp4!cmcl2!manhat!samperi (that's an ell in cmcl2)