[mod.sources] fix to uumail release 2

sources-request@panda.UUCP (12/30/85)

Mod.sources:  Volume 3, Issue 72
Submitted by: Stan Barber <genrad!neuro1!sob>


Just after I sent out the release to mod.sources, a user reported a bug
that was not fixed. The bug happens when you link uumail to uupath
and do uupath "yourhostname", like for me to enter uupath neuro1
(or uumail -w neuro1). This would produce a core dump.
Here is the fix in diff -c format (suitable for use with "patch").

Stan
P.S. Happy new year!

*** uumail.old	Thu Dec 26 16:53:42 1985
--- uumail.c	Thu Dec 26 16:53:46 1985
***************
*** 8,13
   *  to send the mail.
   *  Otherwise it aborts with an error 68 (host unknown)
   * $Log:	uumail.c,v $
   * Revision 2.9  85/12/10  20:36:01  sob
   * Added new return flag from getpath EX_TEMPFAIL to signal that the
   * path database is currently being updated.

--- 8,17 -----
   *  to send the mail.
   *  Otherwise it aborts with an error 68 (host unknown)
   * $Log:	uumail.c,v $
+  * Revision 2.10  85/12/26  16:50:23  sob
+  * Added fixes to allow uupath myhostname to work correctly.
+  * Stan
+  * 
   * Revision 2.9  85/12/10  20:36:01  sob
   * Added new return flag from getpath EX_TEMPFAIL to signal that the
   * path database is currently being updated.
***************
*** 100,106
  char * from;
  
  
! static char Version[] ="$Header: uumail.c,v 2.9 85/12/10 20:36:01 sob Exp $";
  
  main(argc, argv)
  	char **argv;

--- 104,110 -----
  char * from;
  
  
! static char Version[] ="$Header: uumail.c,v 2.10 85/12/26 16:50:23 sob Exp $";
  
  main(argc, argv)
  	char **argv;
***************
*** 310,315
  		if (error == EX_TEMPFAIL) fprintf(stderr,"Database %s is being updated\nTry again later.\n",paths);
  		exit(EX_NOHOST);
  	    }
  	}
      else 
      if (index(p,'@') == NULL) strcpy(path,oupath(p)); 

--- 314,320 -----
  		if (error == EX_TEMPFAIL) fprintf(stderr,"Database %s is being updated\nTry again later.\n",paths);
  		exit(EX_NOHOST);
  	    }
+ 	if (strcmp(path,"%s") == 0) local = 1;
  	}
      else 
      {
***************
*** 312,319
  	    }
  	}
      else 
!     if (index(p,'@') == NULL) strcpy(path,oupath(p)); 
! 	    else strcpy(path,opath(p));
  
  /* fix string to allow % to be untranslated by printf and 
   * friends 

--- 317,325 -----
  	if (strcmp(path,"%s") == 0) local = 1;
  	}
      else 
!     {
! 	if (index(p,'@') == NULL) strcpy(path,oupath(p)); 
! 		    else strcpy(path,opath(p));
  
  /* fix string to allow % to be untranslated by printf and 
   * friends 
***************
*** 318,330
  /* fix string to allow % to be untranslated by printf and 
   * friends 
   */
!    if ((r=index(path,'%')) != NULL)
! 	{
! 		char t[PATHSIZ];
! 		strncpy(t,path,(r-path));
! 		strcat(t,"%");
! 		strcat(t,r);
! 		path = &t[0];
  #ifdef DEBUG
  	if (Debug>3)
  		fprintf(stderr,"In percent fix, %s\n",t);

--- 324,336 -----
  /* fix string to allow % to be untranslated by printf and 
   * friends 
   */
! 	   if ((r=index(path,'%')) != NULL)
! 		{
! 			char t[PATHSIZ];
! 			strncpy(t,path,(r-path));
! 			strcat(t,"%");
! 			strcat(t,r);
! 			path = &t[0];
  #ifdef DEBUG
  		if (Debug>3)
  			fprintf(stderr,"In percent fix, %s\n",t);
***************
*** 326,333
  		strcat(t,r);
  		path = &t[0];
  #ifdef DEBUG
! 	if (Debug>3)
! 		fprintf(stderr,"In percent fix, %s\n",t);
  #endif
  	}
  

--- 332,339 -----
  			strcat(t,r);
  			path = &t[0];
  #ifdef DEBUG
! 		if (Debug>3)
! 			fprintf(stderr,"In percent fix, %s\n",t);
  #endif
  		}
  
***************
*** 329,335
  	if (Debug>3)
  		fprintf(stderr,"In percent fix, %s\n",t);
  #endif
! 	}
  
  
  

--- 335,341 -----
  		if (Debug>3)
  			fprintf(stderr,"In percent fix, %s\n",t);
  #endif
! 		}
  
  
  
***************
*** 338,344
      if (Debug >1) fprintf(stderr,"Opath returns %s\n",path);
  #endif
  
!     if (path[0] == '!')  /* no match in pathalias database */
  	{
  		deadletter(tmpf,local);
  		unlink(templet);

--- 344,350 -----
      if (Debug >1) fprintf(stderr,"Opath returns %s\n",path);
  #endif
  
!     if (path[0] == '!') /* no match in pathalias database */
  	{
  		deadletter(tmpf,local);
  		unlink(templet);
***************
*** 345,351
  		exit(EX_NOHOST);
  	}
     
!    if (strcmp(path,p) == 0)
  	{
  	strcpy(path,Myname);
  	local = 1;

--- 351,357 -----
  		exit(EX_NOHOST);
  	}
     
!    if (strcmp(path,p) == 0 )
  	{
  	strcpy(path,Myname);
  	local = 1;
***************
*** 350,356
  	strcpy(path,Myname);
  	local = 1;
  	}
! 
  #else
  	}
  	else

--- 356,362 -----
  	strcpy(path,Myname);
  	local = 1;
  	}
!     } /* else uupath */
  #else
  	}
  	else
***************
*** 369,378
  
  			}
  	/* insert code here to look at uucp neighbors & local host */
- 	if (bangcnt == 0) {
- 			strcpy(sysname,Myname);
- 			local = 1;
- 			}
  	}
  #ifdef DEBUG
  	if (Debug>1) printf("sysname = %s\n",&name[0]);

--- 375,380 -----
  
  			}
  	/* insert code here to look at uucp neighbors & local host */
  	}
  if (bangcnt == 0) {
  		strcpy(sysname,Myname);
***************
*** 374,379
  			local = 1;
  			}
  	}
  #ifdef DEBUG
  	if (Debug>1) printf("sysname = %s\n",&name[0]);
  #endif

--- 376,385 -----
  			}
  	/* insert code here to look at uucp neighbors & local host */
  	}
+ if (bangcnt == 0) {
+ 		strcpy(sysname,Myname);
+ 		local = 1;
+ 		}
  #ifdef DEBUG
  	if (Debug>1) printf("sysname = %s\n",&name[0]);
  #endif
***************
*** 386,392
  		exit(EX_NOHOST);
  	    }
  
!        if (local) path = sysname;
  #endif
  
  

--- 392,399 -----
  		exit(EX_NOHOST);
  	    }
  
!        if (local) path = "%s";
!        if (strcmp (path,"%s") == 0) local = 1;
  #endif