+Wed Mar 24 17:11:32 1999 Tom Yu <tlyu@mit.edu>
+
+ * 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 <tlyu@mit.edu>
* ftpd.c (user): Remove extra "%s" in call to sprintf() to avoid
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
+#include <sys/ioctl.h>
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>
+#endif
#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/ftp.h>
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 <arpa/telnet.h>
/*
{
register c;
register char *cs;
+ int atmark;
cs = s;
/* tmpline may contain saved command from urgent mode interruption */
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;