[comp.mail.elm] BSD Segmentation fault bug with fix

wpl@burdvax.prc.unisys.com (William P Loftus) (05/18/87)

I'm not sure if this is the same segmentation fault other
people using ELM on BSD (Sun) machines, but it is one cause.

BUG:

   if you have "copy = ON" in your .elmrc, and you invoke elm:

      % elm wpl

   After sending the mail elm would crash with a segmentation fault.

   The problem was in savecopy.c at lineline 82 of 180:


 ---

        if ((errno = can_open(savename, WRITE_ACCESS))) {
          dprint(2, (debugfile,
"Error: attempt to autosave to a file that can't be appended to!\n"));
          dprint(2, (debugfile, "\tfilename = \"%s\"\n", savename));
          dprint(2, (debugfile, "** %s - %s **\n", error_name(errno),
                  error_description(errno)));
          error1("permission to append to %s denied!", savename);
          sleep(2);
          return(FALSE);
        }
 ---

  The parameter WRITE_ACCESS in the call to can_open is wrong.  can_open
  expects the second parameter to be a char* not an integer as WRITE_ACCESS is.
  The fix is to replace WRITE_ACCESS with "a" as done in the following code:

 ---
       if ((errno = can_open(savename, "a"))) {
          dprint(2, (debugfile,  
"Error: attempt to autosave to a file that can't be appended to!\n"));
          dprint(2, (debugfile, "\tfilename = \"%s\"\n", savename));
          dprint(2, (debugfile, "** %s - %s **\n", error_name(errno),
                  error_description(errno)));      
          error1("permission to append to %s denied!", savename);
          sleep(2);
          return(FALSE); 
        } 
 ---

Hope this helps someone.  BTW, ELM 1.5b works fine for me now...


-- 
William P Loftus			UUCP:   wpl@burdvax.UUCP
Unisys/Paoli Research Center		ARPA: 	wpl@burdvax.prc.unisys.com
PO Box 517				BITNET: 202527899@VUVAXCOM
Paoli, PA 19301                         215-648-7222 (work) 215-649-0633 (home)