From f818840fea93cbbcb349aa426459e2849deab42c Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Wed, 24 Mar 1999 22:14:02 +0000 Subject: [PATCH] * ftpcmd.y (urgsafe_getc): New function; like getc() except it retries once if SIOCATMARK returns TRUE. (getline): Use urgsafe_getc() rather than getc() to avoid problems with certain Mac clients that cause the urgent pointer to end up in a location that results in EOF from getc(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11306 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/gssftp/ftpd/ChangeLog | 8 ++++++++ src/appl/gssftp/ftpd/ftpcmd.y | 35 ++++++++++++++++++++++++++++++---- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/appl/gssftp/ftpd/ChangeLog b/src/appl/gssftp/ftpd/ChangeLog index ead623aef..3c7727883 100644 --- a/src/appl/gssftp/ftpd/ChangeLog +++ b/src/appl/gssftp/ftpd/ChangeLog @@ -1,3 +1,11 @@ +Wed Mar 24 17:11:32 1999 Tom Yu + + * ftpcmd.y (urgsafe_getc): New function; like getc() except it + retries once if SIOCATMARK returns TRUE. + (getline): Use urgsafe_getc() rather than getc() to avoid problems + with certain Mac clients that cause the urgent pointer to end up + in a location that results in EOF from getc(). + Fri Mar 12 07:35:01 1999 Tom Yu * ftpd.c (user): Remove extra "%s" in call to sprintf() to avoid diff --git a/src/appl/gssftp/ftpd/ftpcmd.y b/src/appl/gssftp/ftpd/ftpcmd.y index 5b75a4600..acd187112 100644 --- a/src/appl/gssftp/ftpd/ftpcmd.y +++ b/src/appl/gssftp/ftpd/ftpcmd.y @@ -49,6 +49,10 @@ static char sccsid[] = "@(#)ftpcmd.y 5.24 (Berkeley) 2/25/91"; #include #include #include +#include +#ifdef HAVE_SYS_SOCKIO_H +#include +#endif #include #include #include @@ -942,6 +946,26 @@ lookup(p, cmd) return (0); } +/* + * urgsafe_getc - hacked up getc to ignore EOF if SIOCATMARK returns TRUE + */ +int +urgsafe_getc(f) + FILE *f; +{ + register int c; + int atmark; + + c = getc(f); + if (c == EOF) { + if (ioctl(fileno(f), SIOCATMARK, &atmark) != -1) { + c = getc(f); + syslog(LOG_DEBUG, "atmark: c=%d", c); + } + } + return c; +} + #include /* @@ -954,6 +978,7 @@ getline(s, n, iop) { register c; register char *cs; + int atmark; cs = s; /* tmpline may contain saved command from urgent mode interruption */ @@ -969,21 +994,23 @@ getline(s, n, iop) if (c == 0) tmpline[0] = '\0'; } - while ((c = getc(iop)) != EOF) { + while ((c = urgsafe_getc(iop)) != EOF) { c &= 0377; if (c == IAC) { - if ((c = getc(iop)) != EOF) { + if (debug) syslog(LOG_DEBUG, "got IAC"); + if ((c = urgsafe_getc(iop)) != EOF) { c &= 0377; + if (debug) syslog(LOG_DEBUG, "got IAC %d", c); switch (c) { case WILL: case WONT: - c = getc(iop); + c = urgsafe_getc(iop); printf("%c%c%c", IAC, DONT, 0377&c); (void) fflush(stdout); continue; case DO: case DONT: - c = getc(iop); + c = urgsafe_getc(iop); printf("%c%c%c", IAC, WONT, 0377&c); (void) fflush(stdout); continue; -- 2.26.2