On transferring large files tftp / tftpd combo fails to transfer correct file; file is truncated on my checks. Use of '/dev/zero' to populate a "bigfile" created a situation that did not exhibit the problem. Use of '/dev/random' to populate a "bigfile" led to situation that did exhibit problem on 2 out of 2 attempts. When I replaced "/usr/libexec/tftpd" with the ports tftp-hpa "/usr/local/libexec/in.tftpd" did resolve the file transfer issue. I'll note that using the "hpa" version led to some confusion with the tftp client: I was forced to disable "options" to allow the tftp client to work - which seemed a bit off to me. How-To-Repeat: setup server side: > su * enable tftpd in /etc/inetd.conf > cd /tftpboot > dd if=/dev/random of=bigfile bs=21504 count=10000 on same system: > cd /tmp > tftp localhost > get bigfile > ^D > ls -l bigfile
For bugs matching the following criteria: Status: In Progress Changed: (is less than) 2014-06-01 Reset to default assignee and clear in-progress tags. Mail being skipped
Reproducible on FreeBSD 12.
The problem isn't the file's size; it's got to do with the netascii encoding. If a transfer block ends with CR, tftpd erroneously omits the leading NUL from the following transfer block. I have a fix for that. However, what I don't understand is why the bug doesn't occur more often. Sometimes tftp is able to correctly decode the incorrectly-encoded packets, and sometimes it isn't. I don't know why but I've already spent too much time trying to figure it out, so I'm just going to fix the bug in the server instead.
Created attachment 196452 [details] A reproduction case This is the smallest file I could craft that triggers the bug. extract it, then transfer it in netascii mode. One NUL byte will be dropped at about the halfway point.
A commit references this bug: Author: asomers Date: Wed Aug 22 23:31:28 UTC 2018 New revision: 338216 URL: https://svnweb.freebsd.org/changeset/base/338216 Log: tftpd: Fix data corruption bug with netascii Transferring files in netascii format requires, among other things, translating all CR characters to a CR,NUL pair. tftpd does this correctly except when the CR occurs as the last octet of a packet. In that case, it erroneously drops the NUL which should be part of the following packet. The bug was caused by using 0 as a sentinel value in a variable that could legitimately hold 0. Fix it by switching the sentinel value to -1. PR: 178055 Reported by: Richard <rsitze@gmail.com> Reviewed by: cem MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D16853 Changes: head/libexec/tftpd/tftp-file.c
A commit references this bug: Author: asomers Date: Mon Oct 1 16:04:07 UTC 2018 New revision: 339057 URL: https://svnweb.freebsd.org/changeset/base/339057 Log: MFC r338216: tftpd: Fix data corruption bug with netascii Transferring files in netascii format requires, among other things, translating all CR characters to a CR,NUL pair. tftpd does this correctly except when the CR occurs as the last octet of a packet. In that case, it erroneously drops the NUL which should be part of the following packet. The bug was caused by using 0 as a sentinel value in a variable that could legitimately hold 0. Fix it by switching the sentinel value to -1. PR: 178055 Reported by: Richard <rsitze@gmail.com> Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D16853 Changes: _U stable/11/ stable/11/libexec/tftpd/tftp-file.c
A commit references this bug: Author: asomers Date: Mon Oct 1 16:11:09 UTC 2018 New revision: 339062 URL: https://svnweb.freebsd.org/changeset/base/339062 Log: MFC r338216: tftpd: Fix data corruption bug with netascii Transferring files in netascii format requires, among other things, translating all CR characters to a CR,NUL pair. tftpd does this correctly except when the CR occurs as the last octet of a packet. In that case, it erroneously drops the NUL which should be part of the following packet. The bug was caused by using 0 as a sentinel value in a variable that could legitimately hold 0. Fix it by switching the sentinel value to -1. PR: 178055 Reported by: Richard <rsitze@gmail.com> Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D16853 Changes: _U stable/10/ stable/10/libexec/tftpd/tftp-file.c