ftpd can't restart above 32kb
Steven M. Schultz
sms at wlv.imsd.contel.com
Mon Nov 20 10:26:47 AEST 1989
Subject: RESTart in ftpd fails above 32k
Index: etc/ftpd/ftpcmd.y 2.10BSD
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 know 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, recompile and install.
*** 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)" },
More information about the Comp.bugs.2bsd
mailing list