diff options
author | Alan Somers <asomers@FreeBSD.org> | 2018-03-10 01:50:43 +0000 |
---|---|---|
committer | Alan Somers <asomers@FreeBSD.org> | 2018-03-10 01:50:43 +0000 |
commit | 6301d64774c9c58ec727f2386e0f49d0c676305a (patch) | |
tree | ad25909be22ced15168db11e24c1a17b34089664 /libexec | |
parent | b7da179e961d961c70c64f799a29486e39fbb695 (diff) | |
download | src-6301d64774c9c58ec727f2386e0f49d0c676305a.tar.gz src-6301d64774c9c58ec727f2386e0f49d0c676305a.zip |
tftpd: reject unknown opcodes
If tftpd receives a command with an unknown opcode, it simply exits 1. It
doesn't send an ERROR packet, and the client will hang waiting for one. Fix
it.
PR: 226005
MFC after: 3 weeks
Notes
Notes:
svn path=/head/; revision=330720
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/tftpd/tests/functional.c | 1 | ||||
-rw-r--r-- | libexec/tftpd/tftpd.c | 6 |
2 files changed, 3 insertions, 4 deletions
diff --git a/libexec/tftpd/tests/functional.c b/libexec/tftpd/tests/functional.c index 089765a3908e..fea6870cac59 100644 --- a/libexec/tftpd/tests/functional.c +++ b/libexec/tftpd/tests/functional.c @@ -677,7 +677,6 @@ TFTPD_TC_DEFINE(unknown_opcode,) { /* Looks like an RRQ or WRQ request, but with a bad opcode */ SEND_STR("\0\007foo.txt\0octet\0"); - atf_tc_expect_timeout("PR 226005 tftpd ignores bad opcodes but doesn't reject them"); RECV_ERROR(4, "Illegal TFTP operation"); } diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c index b3ce91468d38..976a58a0ef58 100644 --- a/libexec/tftpd/tftpd.c +++ b/libexec/tftpd/tftpd.c @@ -421,8 +421,7 @@ main(int argc, char *argv[]) "%s read access denied", peername); exit(1); } - } - if (tp->th_opcode == WRQ) { + } else if (tp->th_opcode == WRQ) { if (allow_wo) tftp_wrq(peer, tp->th_stuff, n - 1); else { @@ -430,7 +429,8 @@ main(int argc, char *argv[]) "%s write access denied", peername); exit(1); } - } + } else + send_error(peer, EBADOP); exit(1); } |