summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMartynas Venckus <martynas@cvs.openbsd.org>2009-04-25 12:22:20 +0000
committerMartynas Venckus <martynas@cvs.openbsd.org>2009-04-25 12:22:20 +0000
commitf2d540b6158877e17b059138578b9307c4eb461b (patch)
tree010dd58f12ad18d8ef5679cd3a8b44a008c0b56d /usr.bin
parenta1c1dc2b20fa9f7b47586a8604a172e5f273f2b7 (diff)
guard NOOP code (that tries to send remaining NOOP string) after
server closes connection during any get/put transfer. it dereferences cout, which will be NULL, oops originally reported on misc@. pirofti@ can't reproduce it again since the server has been fixed tested by simulating the very same failure sthen@ and pirofti@ agree that my analysis is correct ok sthen@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ftp/ftp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/ftp/ftp.c b/usr.bin/ftp/ftp.c
index 44f4297852e..a1c19bc2a5b 100644
--- a/usr.bin/ftp/ftp.c
+++ b/usr.bin/ftp/ftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ftp.c,v 1.73 2008/07/08 21:07:57 martynas Exp $ */
+/* $OpenBSD: ftp.c,v 1.74 2009/04/25 12:22:19 martynas Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */
/*
@@ -60,7 +60,7 @@
*/
#if !defined(lint) && !defined(SMALL)
-static const char rcsid[] = "$OpenBSD: ftp.c,v 1.73 2008/07/08 21:07:57 martynas Exp $";
+static const char rcsid[] = "$OpenBSD: ftp.c,v 1.74 2009/04/25 12:22:19 martynas Exp $";
#endif /* not lint and not SMALL */
#include <sys/types.h>
@@ -365,6 +365,12 @@ may_receive_noop_ack()
{
int i;
+ if (cout == NULL) {
+ /* Lost connection; so just pretend we're fine. */
+ current_nop_pos = full_noops_sent = 0;
+ return;
+ }
+
/* finish sending last incomplete noop */
if (current_nop_pos != 0) {
fputs(&(noop[current_nop_pos]), cout);