Author: asomers
Date: Fri Aug  3 14:19:56 2018
New Revision: 337250
URL: https://svnweb.freebsd.org/changeset/base/337250

Log:
  MFC r330720:
  
  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

Modified:
  stable/10/libexec/tftpd/tests/functional.c
  stable/10/libexec/tftpd/tftpd.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/libexec/tftpd/tests/functional.c
==============================================================================
--- stable/10/libexec/tftpd/tests/functional.c  Fri Aug  3 14:19:09 2018        
(r337249)
+++ stable/10/libexec/tftpd/tests/functional.c  Fri Aug  3 14:19:56 2018        
(r337250)
@@ -675,7 +675,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");
 }
 

Modified: stable/10/libexec/tftpd/tftpd.c
==============================================================================
--- stable/10/libexec/tftpd/tftpd.c     Fri Aug  3 14:19:09 2018        
(r337249)
+++ stable/10/libexec/tftpd/tftpd.c     Fri Aug  3 14:19:56 2018        
(r337250)
@@ -419,8 +419,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 {
@@ -428,7 +427,8 @@ main(int argc, char *argv[])
                            "%s write access denied", peername);
                        exit(1);
                }
-       }
+       } else
+               send_error(peer, EBADOP);
        exit(1);
 }
 
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to