Article View: comp.bugs.4bsd
Article #139ftpd RESTart above 32k can fail
From: Steven M. Schultz
Date: Sun, 19 Nov 1989 23:30
Date: Sun, 19 Nov 1989 23:30
73 lines
2911 bytes
2911 bytes
Subject: RESTart in ftpd fails above 32k
Index: etc/ftpd/ftpcmd.y 4.3BSD
Description:
Attempting to RESTart a file transfer when the remote daemon
is running on a machine where "sizeof (int) != sizeof (long)"
fails when the offset/restartpoint is above 32767.
The problem is (yet another *sigh *) long vs. int one.
One would think that "sizeof (int) != sizeof (long)" would
be a more widely known fact, but alas not.
The RESTart offset should be treated as a string and converted
via atol() when needed. In fact, the "long atol()" declaration
was present in ftpcmd.y - but the function was never called.
Repeat-By:
Connect to a ftp servor on a machine (likely a pdp-11) where
"sizeof (int) != sizeof (long)" and do a "reget file" where
the starting point would be > 32767. Observe the error message
and the mangled number (result of sign extending a short to a
long.
Fix:
Apply the following patch to ftpcmd.y on the system which won't
restart above 32k .
*** ftpcmd.y.old Wed May 10 14:13:13 1989
--- ftpcmd.y Sun Nov 19 17:52:30 1989
***************
*** 488,499 ****
}
}
}
! | REST SP byte_size CRLF
= {
long atol();
fromname = (char *) 0;
! restart_point = $3;
reply(350, "Restarting at %ld. %s", restart_point,
"Send STORE or RETRIEVE to initiate transfer.");
}
--- 488,499 ----
}
}
}
! | REST SP STRING CRLF
= {
long atol();
fromname = (char *) 0;
! restart_point = atol($3);
reply(350, "Restarting at %ld. %s", restart_point,
"Send STORE or RETRIEVE to initiate transfer.");
}
***************
*** 712,718 ****
{ "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" },
{ "MRCP", MRCP, STR1, 0, "(mail recipient)" },
{ "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" },
! { "REST", REST, ARGS, 1, "(restart command)" },
{ "RNFR", RNFR, STR1, 1, "<sp> file-name" },
{ "RNTO", RNTO, STR1, 1, "<sp> file-name" },
{ "ABOR", ABOR, ARGS, 1, "(abort operation)" },
--- 712,718 ----
{ "MRSQ", MRSQ, OSTR, 0, "(mail recipient scheme question)" },
{ "MRCP", MRCP, STR1, 0, "(mail recipient)" },
{ "ALLO", ALLO, ARGS, 1, "allocate storage (vacuously)" },
! { "REST", REST, STR1, 1, "(restart command)" },
{ "RNFR", RNFR, STR1, 1, "<sp> file-name" },
{ "RNTO", RNTO, STR1, 1, "<sp> file-name" },
{ "ABOR", ABOR, ARGS, 1, "(abort operation)" },
Technical Details
Message-ID:
<40919@wlbr.IMSD.CONTEL.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!samsung!usc!apple!voder!wlbr!wlv.imsd.contel.com!smsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!samsung!usc!apple!voder!wlbr!wlv.imsd.contel.com!sms From: sms@wlv.imsd.contel.com (Steven M. Schultz) Newsgroups: comp.bugs.4bsd Subject: ftpd RESTart above 32k can fail Message-ID: <40919@wlbr.IMSD.CONTEL.COM> Date: 19 Nov 89 23:30:42 GMT Sender: news@wlbr.IMSD.CONTEL.COM Reply-To: sms@wlv.imsd.contel.com (Steven M. Schultz) Organization: Contel Federal Systems Lines: 73