summaryrefslogtreecommitdiff
path: root/libexec/tftpd
Commit message (Collapse)AuthorAgeFilesLines
* When receiving a file having a length, which is a mulitple of the blocksize,Michael Tuexen2020-12-151-2/+2
| | | | | | | | | | close the file once it is received. Reported by: Timo Voelker MFC after: 1 week Notes: svn path=/head/; revision=368657
* Improve the counting of blocks used to transfer a file from theMichael Tuexen2020-12-141-1/+1
| | | | | | | | | | server to the client in case of not using an OACK: Don't miss the first block in case of it is not also the last one. MFC after: 1 week Notes: svn path=/head/; revision=368647
* Fix the TFTP client when performing a RRQ for files smaller than 512 bytesMichael Tuexen2020-12-101-0/+2
| | | | | | | | | | | and the server not sending an OACK: * Close the file. * Report the correct the number of received blocks. MFC after: 1 week Notes: svn path=/head/; revision=368521
* When dropping packets (RRQ or WRQ) for debugging, report the sendMichael Tuexen2020-12-061-2/+2
| | | | | | | | | | operation as successful. Reporting a failure stops the transfer instead of using timeouts. MFC after: 1 week Notes: svn path=/head/; revision=368394
* Do a sweep and remove most WARNS=6 settingsKyle Evans2020-10-011-1/+0
| | | | | | | | | | | | | | | Repeating the default WARNS here makes it slightly more difficult to experiment with default WARNS changes, e.g. if we did something absolutely bananas and introduced a WARNS=7 and wanted to try lifting the default to that. Drop most of them; there is one in the blake2 kernel module, but I suspect it should be dropped -- the default WARNS in the rest of the build doesn't currently apply to kernel modules, and I haven't put too much thought into whether it makes sense to make it so. Notes: svn path=/head/; revision=366304
* tftpd: Check for errors from chdir()Mark Johnston2020-09-221-1/+4
| | | | | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=366002
* Remove tests for obsolete compilers in the build systemEric van Gyzen2020-05-121-3/+0
| | | | | | | | | | | | | | Assume gcc is at least 6.4, the oldest xtoolchain in the ports tree. Assume clang is at least 6, which was in 11.2-RELEASE. Drop conditions for older compilers. Reviewed by: imp (earlier version), emaste, jhb MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D24802 Notes: svn path=/head/; revision=360964
* Abort transfer if fseeko() fails.John Baldwin2020-04-211-3/+23
| | | | | | | | | | | CID: 1420215 Reviewed by: asomers MFC after: 1 week Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24454 Notes: svn path=/head/; revision=360167
* tftpd: tests: raise targeted cstd to c11Kyle Evans2020-03-051-0/+1
| | | | | | | | | | r358556 added alignas() use to the functional tests, which isn't defined until C11. Raise the -std to C11 to fix the build under freebsd-gcc{6,9}. Reported by: mhorne, Jenkins/CI Notes: svn path=/head/; revision=358687
* Add support for the TFTP windowsize option described in RFC 7440.John Baldwin2020-03-029-49/+422
| | | | | | | | | | | | | | The windowsize option permits multiple blocks to be transmitted before the receiver sends an ACK improving throughput for larger files. Reviewed by: asomers MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23836 Notes: svn path=/head/; revision=358556
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-2/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* Add Makefile.depend.optionsSimon J. Gerraty2019-12-111-0/+6
| | | | | | | | | | | | | | | | | | | | Leaf directories that have dependencies impacted by options need a Makefile.depend.options file to avoid churn in Makefile.depend DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc can be set in local.dirdeps-options.mk which can add to those set in Makefile.depend.options See share/mk/dirdeps-options.mk Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22469 Notes: svn path=/head/; revision=355616
* Drop "All rights reserved" from the files I ownAlan Somers2019-03-111-1/+2
| | | | | | | | | Also, add SPDX tags where needed. MFC after: 2 weeks Notes: svn path=/head/; revision=345034
* tftpd: Fix data corruption bug with netasciiAlan Somers2018-08-221-5/+5
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=338216
* Fix several Coverity warnings in tftpAlan Somers2018-07-222-9/+11
| | | | | | | | | | | | | | | | | Some of the changes are in the libexec/tftpd directory, but to functions that are only used by tftp(1) (they share some code). * strcpy => strlcpy (1006793, 1006794, 1006796, 1006741) * Unchecked return value and TOCTTOU (1009314) * NULL pointer dereference (1018035, 1018036) Reported by: Coverity CID: 1006793, 1006794, 1006796, 1006741, 1009314, 1018035 CID: 1018036 MFC after: 2 weeks Notes: svn path=/head/; revision=336609
* Fix multiple Coverity warnings in tftpd(8)Alan Somers2018-07-224-17/+17
| | | | | | | | | | | | | | | | * Initialize uninitialized variable (CID 1006502) * strcpy => strlcpy (CID 1006792, 1006791, 1006790) * Check function return values (CID 1009442, 1009441, 1009440) * Delete dead code in receive_packet (not reported by Coverity) * Remove redundant alarm(3) in receive_packet (not reported by Coverity) Reported by: Coverity CID: 1006502, 1006792, 1006791, 1006790, 1009442, 1009441, 1009440 MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D11287 Notes: svn path=/head/; revision=336605
* tftpd(8): when completing an WRQ, flush the file before acknowleding receiptAlan Somers2018-07-211-2/+2
| | | | | | | | | | | | | tftpd(8) should flush a newly written file to disk before ACKing the final DATA packet. Otherwise there is a narrow race window when a subsequent read may not see the file. This is somewhat related to r330710, but the race window is much smaller. Hopefully this will fix the intermittent tests in Jenkins. Reported by: Jenkins MFC after: 2 weeks Notes: svn path=/head/; revision=336587
* tftpd: misc Coverity cleanup in the testsAlan Somers2018-03-221-7/+12
| | | | | | | | | | | | | A bunch of unchecked return values from open(2) and read(2) Reported by: Coverity CID: 1386900, 1386911, 1386926, 1386928, 1386932, 1386942 CID: 1386961, 1386979 MFC after: 8 days X-MFC-With: 330696 Notes: svn path=/head/; revision=331358
* tftpd: fix the build of tests on i386 after 330696Alan Somers2018-03-101-2/+2
| | | | | | | | | | | It's those darn printf format specifiers again Reported by: cy, kibab MFC after: 20 days X-MFC-With: 330696 Notes: svn path=/head/; revision=330742
* tftpd: reject unknown opcodesAlan Somers2018-03-102-4/+3
| | | | | | | | | | | | 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: svn path=/head/; revision=330720
* tftpd: Abort on an WRQ access violationAlan Somers2018-03-102-6/+4
| | | | | | | | | | | | | | | | | | On a WRQ (write request) tftpd checks whether the client has access permission for the file in question. If not, then the write is prevented. However, tftpd doesn't reply with an ERROR packet, nor does it abort. Instead, it tries to receive the packet anyway. The symptom is slightly different depending on the nature of the error. If the target file is nonexistent and tftpd lacks permission to create it, then tftpd will willingly receive the file, but not write it anywhere. If the file exists but is not writable, then tftpd will fail to ACK to WRQ. PR: 225996 MFC after: 3 weeks Notes: svn path=/head/; revision=330719
* tftpd: Verify world-writability for WRQ when using relative pathsAlan Somers2018-03-102-6/+17
| | | | | | | | | | | | | | | | | | tftpd(8) says that files may only be written if they already exist and are publicly writable. tftpd.c verifies that a file is publicly writable if it uses an absolute pathname. However, if the pathname is relative, that check is skipped. Fix it. Note that this is not a security vulnerability, because the transfer ultimately doesn't work unless the file already exists and is owned by user nobody. Also, this bug does not affect the default configuration, because the default uses the "-s" option which makes all pathnames absolute. PR: 226004 MFC after: 3 weeks Notes: svn path=/head/; revision=330718
* tftpd: Flush files as soon as they are fully receivedAlan Somers2018-03-093-9/+3
| | | | | | | | | | | | | | | | | | On an RRQ, tftpd doesn't exit as soon as it's finished receiving a file. Instead, it waits five seconds just in case the client didn't receive the server's last ACK and decides to resend the final DATA packet. Unfortunately, this created a 5 second delay from when the client thinks it's done sending the file, and when the file is available for other processes. Fix this bug by closing the file as soon as receipt is finished. PR: 157700 Reported by: Barry Mishler <barry_mishler@yahoo.com> MFC after: 3 weeks Notes: svn path=/head/; revision=330710
* Add some functional tests for tftpd(8)Alan Somers2018-03-093-0/+1023
| | | | | | | | | | | | | | | | | | | tftpd(8) is difficult to test in isolation due to its relationship with inetd. Create a test program that mimics the behavior of tftp(1) and inetd(8) and verifies tftpd's response in several different scenarios. These test cases cover all of the basic TFTP protocol, but not the optional parts. PR: 157700 PR: 225996 PR: 226004 PR: 226005 MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D14310 Notes: svn path=/head/; revision=330696
* libexec: adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-2710-10/+30
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326274
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-1/+3
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Notes: svn path=/head/; revision=326025
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* Conditionalize all code that uses tcpd.h behind `LIBWRAP` guardEnji Cooper2017-01-062-1/+11
| | | | | | | | | This will allow the code to stand by itself without libwrap MFC after: 2 weeks Notes: svn path=/head/; revision=311473
* Add META_MODE support.Simon J. Gerraty2015-06-131-0/+20
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp Notes: svn path=/head/; revision=284345
| * dirdeps.mk now sets DEP_RELDIRSimon J. Gerraty2015-06-081-2/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=284172
| * Merge sync of headSimon J. Gerraty2015-05-271-2/+1
| |\ | |/ |/| | | Notes: svn path=/projects/bmake/; revision=283595
| * Updated dependenciesSimon J. Gerraty2014-05-161-1/+0
| | | | | | | | Notes: svn path=/projects/bmake/; revision=266219
| * Updated dependenciesSimon J. Gerraty2014-05-101-0/+2
| | | | | | | | Notes: svn path=/projects/bmake/; revision=265802
| * Merge headSimon J. Gerraty2014-04-282-10/+2
| |\ | | | | | | | | | Notes: svn path=/projects/bmake/; revision=265044
| * | Updated dependenciesSimon J. Gerraty2013-03-111-0/+1
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=248169
| * | Updated dependenciesSimon J. Gerraty2013-02-161-2/+0
| | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246868
| * | Sync with HEAD.David E. O'Brien2013-02-084-18/+19
| |\ \ | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=246555
| * \ \ Sync from headSimon J. Gerraty2012-11-043-6/+9
| |\ \ \ | | | | | | | | | | | | | | | Notes: svn path=/projects/bmake/; revision=242545
| * | | | Sync FreeBSD's bmake branch with Juniper's internal bmake branch.Marcel Moolenaar2012-08-221-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: Simon Gerraty <sjg@juniper.net> Notes: svn path=/projects/bmake/; revision=239572
* | | | | Convert to LIBADDBaptiste Daroussin2014-11-251-2/+1
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | Reduce overlinking Notes: svn path=/head/; revision=275077
* | | | Remove the 3rd clause ("advertising clause") of the BSD license asChristian Brueffer2014-02-172-10/+2
| |_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | permitted by the University of Berkeley on July 22, 1999. Reviewed by: imp MFC after: 1 week Notes: svn path=/head/; revision=262136
* | | Mark tftp_log() as __printflike() (which would have caught the bugMarius Strobl2013-01-314-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | fixed in r246106) and deal with the fallout. MFC after: 2 weeks Notes: svn path=/head/; revision=246139
* | | Remove extra %s from debug statement that ends up crashing tftpd ifSean Bruno2013-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | debug is set very high (like -d15 in my case). Obtained from: Yahoo! Inc MFC after: 2 weeks Notes: svn path=/head/; revision=246106
* | | Use correct size in snprintf.Antoine Brodin2012-12-251-2/+1
| |/ |/| | | | | | | | | | | | | | | | | | | Remove unused buffer. PR: 174631 Submitted by: Henning Petersen MFC after: 1 month Notes: svn path=/head/; revision=244686
* | Check the return error of set[e][ug]id. While this can never fail in theEitan Adler2012-10-221-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | current version of FreeBSD, this isn't guarenteed by the API. Custom security modules, or future implementations of the setuid and setgid may fail. Submitted by: Erik Cederstrand Approved by: cperciva MFC after: 3 days Notes: svn path=/head/; revision=241848
* | Fix warnings found by -Wmising-variable-declarations.Ed Schouten2012-10-193-5/+5
|/ | | | | | | | | | | | | | This self-written compiler warning, which is hopefully going to be committed into LLVM sources soon, warns about potentially missing `static' keywords, similar to -Wmissing-prototypes. - bin/pax: Move external declaration of chdname and s_mask into extern.h. - bin/setfacl: Move setfacl.c-specific stuff out of setfacl.h. - sbin/mount_fusefs: Remove char *progname; use getprogname(). - others: add `static' where possible. Notes: svn path=/head/; revision=241720
* mdoc: Only use macros inside a reference block.Joel Dahl2012-05-231-8/+4
| | | | Notes: svn path=/head/; revision=235857
* Properly use LDADD & DPADD to link against libwrap.Marcel Moolenaar2012-05-191-1/+3
| | | | Notes: svn path=/head/; revision=235643
* Remove trailing whitespace per mdoc lint warningEitan Adler2012-03-291-3/+3
| | | | | | | | | | Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days Notes: svn path=/head/; revision=233648
* Avoid error log for transfer stop w/o error code.Ed Maste2012-02-211-1/+2
| | | | | | | | | | | | | A number of tftp clients, including the one in Intel's pxe boot loader, may intentionally stop a transfer using error code 0 (i.e., EUNDEF). These are not real errors. Avoid spamming log files with these by logging them at level LOG_DEBUG instead. Discussed on -hackers with an initial patch proposal; this change is an improved approach suggested by kan@. Notes: svn path=/head/; revision=231973