Commit d1377fa3 authored by Simon Kelley's avatar Simon Kelley

Account for TFTP packet headers in IPv6 correctly.

parent fa79466c
...@@ -346,14 +346,15 @@ void tftp_request(struct listener *listen, time_t now) ...@@ -346,14 +346,15 @@ void tftp_request(struct listener *listen, time_t now)
{ {
if ((opt = next(&p, end)) && !option_bool(OPT_TFTP_NOBLOCK)) if ((opt = next(&p, end)) && !option_bool(OPT_TFTP_NOBLOCK))
{ {
/* 32 bytes for IP, UDP and TFTP headers, 52 bytes for IPv6 */
int overhead = (listen->family == AF_INET) ? 32 : 52;
transfer->blocksize = atoi(opt); transfer->blocksize = atoi(opt);
if (transfer->blocksize < 1) if (transfer->blocksize < 1)
transfer->blocksize = 1; transfer->blocksize = 1;
if (transfer->blocksize > (unsigned)daemon->packet_buff_sz - 4) if (transfer->blocksize > (unsigned)daemon->packet_buff_sz - 4)
transfer->blocksize = (unsigned)daemon->packet_buff_sz - 4; transfer->blocksize = (unsigned)daemon->packet_buff_sz - 4;
/* 32 bytes for IP, UDP and TFTP headers */ if (mtu != 0 && transfer->blocksize > (unsigned)mtu - overhead)
if (mtu != 0 && transfer->blocksize > (unsigned)mtu - 32) transfer->blocksize = (unsigned)mtu - overhead;
transfer->blocksize = (unsigned)mtu - 32;
transfer->opt_blocksize = 1; transfer->opt_blocksize = 1;
transfer->block = 0; transfer->block = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment