Subject: bin/1345: tip fixes
To: None <gnats-bugs@NetBSD.ORG>
From: None <matthieu@laas.fr>
List: netbsd-bugs
Date: 08/12/1995 17:24:58
>Number:         1345
>Category:       bin
>Synopsis:       fixes dumps core when using ~>  and cannot be restarted
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 12 11:35:01 1995
>Last-Modified:
>Originator:     Matthieu Herrb
>Organization:
		LAAS/CNRS - Toulouse France
>Release:        Aug 10 1995
>Environment:
	directory: /usr/src/usr.bin/tip
	rcs Ids of files:
	$NetBSD: cmds.c,v 1.4 1994/12/24 17:56:23 cgd Exp $
	$NetBSD: uucplock.c,v 1.5 1994/12/24 17:56:30 cgd Exp $

System: NetBSD cougar 1.0A NetBSD 1.0A (COUGAR) #5: Fri Aug 11 22:14:30 MET DST 1995 matthieu@cougar:/usr/src/sys/arch/i386/compile/COUGAR i386


>Description:
	1. If 'eofwrite' is undefined, tip dumps core when using the ~> 
           file transfer command
	2. If a stale lock exists tip cannot override it, emitting the 
           following message:

		Stale lock on tty01 PID=18111... overriding.
		/var/spool/lock/LCK..tty01: Invalid argument
		Can't seek lock file.

>How-To-Repeat:

	start tip with a remote entry that does not define the 'oe'
	capacity, for instance:

		tty01:dv=/dev/tty01:br#9600:pa=none:
	
	then send a file using ~>

	after the tip crash, try to restart it to observ the 2nd
	problem.

>Fix:
	Apply this patch:

--- cmds.c~	Sun Dec 25 12:30:28 1994
+++ cmds.c	Sat Aug 12 17:16:13 1995
@@ -364,8 +364,9 @@
 out:
 	if (lastc != '\n' && !boolean(value(RAWFTP)))
 		send('\r');
-	for (pc = eofchars; *pc; pc++)
-		send(*pc);
+	if (eofchars != NOSTR)
+	        for (pc = eofchars; *pc; pc++)
+		        send(*pc);
 	stop_t = time(0);
 	fclose(fd);
 	signal(SIGINT, f);
--- uucplock.c~	Sun Dec 25 12:30:30 1994
+++ uucplock.c	Sat Aug 12 17:10:11 1995
@@ -41,6 +41,7 @@
 #endif /* not lint */
 
 #include <stdio.h>
+#include <unistd.h>
 #include <string.h>
 #include <sys/types.h>
 #include <sys/file.h>
@@ -60,7 +61,6 @@
 	extern int errno;
 	int fd, pid;
 	char tbuf[sizeof(_PATH_LOCKDIRNAME) + MAXNAMLEN];
-	off_t lseek();
 	char text_pid[81];
 	int len;
 
@@ -97,7 +97,7 @@
 		 */
 		fprintf(stderr, "Stale lock on %s PID=%d... overriding.\n",
 			ttyname, pid);
-		if (lseek(fd, 0L, L_SET) < 0) {
+		if (lseek(fd, (off_t)0, L_SET) < 0) {
 			perror(tbuf);
 			(void)close(fd);
 			fprintf(stderr, "Can't seek lock file.\n");
>Audit-Trail:
>Unformatted: