tftpd-hpa sends a confusing error message if the filename is zero-length.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
tftp-hpa (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
We were getting an error message like this in the logs:
Oct 9 01:21:39 hostname in.tftpd[192773]: sending NAK (4, Missing mode) to 10.0.0.10
This caused much confusion until we realized that the problem was our TFTP client was sending an RRQ message with a zero-length filename. Looking at the code, it doesn't check that case so it gives the wrong error about the mode instead.
I took a look at the source and I propose this patch to fix the problem:
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index 364e7d2..e2659e0 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -1085,6 +1085,11 @@ int tftp(struct tftphdr *tp, int size)
end = (char *)tp + size;
+ if (!*cp) {
+ nak(EBADOP, "Zero-length filename.");
+ exit(0);
+ }
+
while (cp < end && *cp) {
do {
cp++;
$ lsb_release -rd
Description: Ubuntu 20.04.2 LTS
Release: 20.04
$ apt-cache policy tftpd-hpa
tftpd-hpa:
Installed: 5.2+20150808-
Candidate: 5.2+20150808-
Version table:
*** 5.2+20150808-
500 http://
100 /var/lib/
Attaching the patch I came up with.