[PATCH v2 2/2] tftp: ignore trailing garbage in the request
Aaro Koskinen
aaro.koskinen at iki.fi
Wed Sep 3 21:06:23 UTC 2014
Hi,
On Wed, Sep 03, 2014 at 06:36:36PM +0200, Denys Vlasenko wrote:
> On Mon, Sep 1, 2014 at 10:24 PM, Aaro Koskinen <aaro.koskinen at iki.fi> wrote:
> > The firmware in some HP PA-RISC boxes is always sending fixed
> > 512-byte requests, and sometimes there is some garbage at the end
> > which makes busybox to reject the request. Ignore any characters after
> > the last NUL.
>
> How about this?
As you pointed out, I missed the short read possibility, and by
ignoring them that also made me to screw up my testing & analysis
(should have checked with tcpdump) - the box is actually sending
*516-byte* requests. :-(
So following is still needed to current git to work with some PA-RISC:
diff --git a/networking/tftp.c b/networking/tftp.c
index 8e3b0a2..d9295c9 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -118,7 +118,7 @@ struct globals {
uint8_t error_pkt[4 + 32];
struct passwd *pw;
/* used in tftpd_main(), a bit big for stack: */
- char block_buf[TFTP_BLKSIZE_DEFAULT];
+ char block_buf[TFTP_BLKSIZE_DEFAULT + 4];
char block_buf_tail[1];
#if ENABLE_FEATURE_TFTP_PROGRESS_BAR
off_t pos;
@@ -811,7 +811,7 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
) {
goto err;
}
- /* Some HP PA-RISC firmware always sends fixed 512-byte requests,
+ /* Some HP PA-RISC firmware always sends fixed 516-byte requests,
* with trailing garbage.
* Support that by not requiring NUL to be the last byte (see above).
* To make strXYZ() ops safe, force NUL termination:
Very sorry not realizing this earlier,
A.
More information about the busybox
mailing list