=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ftp/ftp.c,v retrieving revision 1.86 retrieving revision 1.87 diff -c -r1.86 -r1.87 *** src/usr.bin/ftp/ftp.c 2014/05/20 01:25:23 1.86 --- src/usr.bin/ftp/ftp.c 2014/08/16 07:49:27 1.87 *************** *** 1,4 **** ! /* $OpenBSD: ftp.c,v 1.86 2014/05/20 01:25:23 guenther Exp $ */ /* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: ftp.c,v 1.87 2014/08/16 07:49:27 deraadt Exp $ */ /* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */ /* *************** *** 317,327 **** void cmdabort(int signo) { alarmtimer(0); ! putc('\n', ttyout); ! (void)fflush(ttyout); abrtflag++; if (ptflag) longjmp(ptabort, 1); } --- 317,329 ---- void cmdabort(int signo) { + int save_errno = errno; alarmtimer(0); ! (void) write(fileno(ttyout), "\n\r", 2); abrtflag++; + + errno = save_errno; if (ptflag) longjmp(ptabort, 1); } *************** *** 575,586 **** void abortsend(int signo) { ! alarmtimer(0); mflag = 0; abrtflag = 0; ! fputs("\nsend aborted\nwaiting for remote to finish abort.\n", ttyout); ! (void)fflush(ttyout); longjmp(sendabort, 1); } --- 577,591 ---- void abortsend(int signo) { ! int save_errno = errno; alarmtimer(0); mflag = 0; abrtflag = 0; ! #define MSG "\nsend aborted\nwaiting for remote to finish abort.\n" ! (void) write(fileno(ttyout), MSG, strlen(MSG)); ! #undef MSG ! ! errno = save_errno; longjmp(sendabort, 1); } *************** *** 2040,2053 **** static void abortforce(int signo) { ! fputs("Forced abort. The connection will be closed.\n", ttyout); ! (void)fflush(ttyout); ! if (cout) { ! (void)fclose(cout); ! } ! cout = NULL; longjmp(forceabort, 1); } --- 2045,2057 ---- static void abortforce(int signo) { ! int save_errno = errno; ! #define MSG "Forced abort. The connection will be closed.\n" ! (void) write(fileno(ttyout), MSG, strlen(MSG)); ! #undef MSG + errno = save_errno; longjmp(forceabort, 1); } *************** *** 2061,2066 **** --- 2065,2072 ---- sig_t oldintr; if (cout == NULL || setjmp(forceabort)) { + if (cout) + fclose(cout); warnx("Lost control connection for abort."); if (ptabflg) code = -1;