History log of /freebsd-current/usr.bin/tftp/main.c
Revision Date Author Comments
# 0b8224d1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

Remove copyright strings ifdef'd out

We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by: Netflix


# bdcbfde3 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 92570f67 10-Mar-2023 Dag-Erling Smørgrav <des@FreeBSD.org>

tftp: Correctly propagate transfer errors.

Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D38958


# b9fabe99 18-Nov-2022 Dag-Erling Smørgrav <des@FreeBSD.org>

tftp: cleanup

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37433


# b15e052e 18-Nov-2022 Dag-Erling Smørgrav <des@FreeBSD.org>

tftpd: Plug memory leaks in option handling code.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37423


# 9f9544fd 17-Nov-2022 Dag-Erling Smørgrav <des@FreeBSD.org>

tftp: Fix buffer overflow and fd leak in multi-file PUT.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37422


# fdf929ff 02-Mar-2020 John Baldwin <jhb@FreeBSD.org>

Add support for the TFTP windowsize option described in RFC 7440.

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


# 123d18b5 03-Oct-2019 Alan Somers <asomers@FreeBSD.org>

tftp: fix two minor Coverity CIDs

Reported by: Coverity
CID 1394842: file descriptor leak in an error path
CID 1007603: single byte array overflow
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D21695


# 7dbe228c 23-Aug-2018 Alan Somers <asomers@FreeBSD.org>

tftp(1): switch default transfer mode to binary

netascii is obsolete and inefficient. It isn't even supported by many
clients. Better to use binary mode by default.

Reviewed by: cem
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D16869


# e4036974 14-Aug-2018 Alan Somers <asomers@FreeBSD.org>

tftp: Close a resource leak when putting files

Reported by: Coverity
CID: 1394842
MFC after: 2 weeks


# ca2d3691 22-Jul-2018 Alan Somers <asomers@FreeBSD.org>

Fix several Coverity warnings in tftp

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


# e4803b1c 10-Feb-2018 Justin Hibbits <jhibbits@FreeBSD.org>

Fix uninitialized warning, and work around a bug in gcc over clobbering

Summary:
r329077 caused gcc to emit uninitialized use warnings. Attempting to
fix those warnings yielded the following warnings:

usr.bin/tftp/main.c: In function 'main':
usr.bin/tftp/main.c:181: warning: variable 'el' might be clobbered by
'longjmp' or 'vfork'
usr.bin/tftp/main.c:182: warning: variable 'hist' might be clobbered by
'longjmp' or 'vfork'

This is a known bug in gcc, found at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24239

Work around that by simply marking hist and el as static.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D14302


# 51adff93 09-Feb-2018 Conrad Meyer <cem@FreeBSD.org>

tftp(1): Clean up leading and trailing whitespace

Whitespace-only change.

Sponsored by: Dell EMC Isilon


# 49fb0615 09-Feb-2018 Conrad Meyer <cem@FreeBSD.org>

tftp(1): Fix libedit state corruption involving signals

This bug was first reported 14 years ago. The problem was understood 8.5
years ago. A patch that is functionally identical to this one was proposed
almost 8 years ago and languished in the PR system / Bugzilla.

PR: 63197
Submitted by: lxv AT omut.org, fernando.apesteguia AT gmail.com
Reported by: freebsd AT nbritton.org


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

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.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# a9a46bd9 26-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use MIN() macro from sys/param.h.

MFC after: 2 weeks.


# 6b1c4644 19-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Partially revert the change on r298325 where there is an
(-1) casted to a pointer.

Submitted by: pfg
MFC after: 2 weeks.


# b4b3d271 19-Apr-2016 Marcelo Araujo <araujo@FreeBSD.org>

Use NULL instead of 0 for pointers.
Small cosmetic change.

MFC after: 2 weeks.


# 32e49abe 31-Aug-2015 Xin LI <delphij@FreeBSD.org>

- uri is expected to be nul-terminated (strchr used later),
so use strlcpy instead of strncpy.
- unroll the other two cases of strncpy+\0 to strlcpy.

MFC after: 2 weeks


# 0f8d6cfc 03-Mar-2014 Marcel Moolenaar <marcel@FreeBSD.org>

Increase MAXLINE to deal with longer paths.

Obtained from: Juniper Networks, Inc.


# bf70bece 19-Oct-2012 Ed Schouten <ed@FreeBSD.org>

More -Wmissing-variable-declarations fixes.

In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.


# a3a2bf4b 12-Jan-2012 Kevin Lo <kevlo@FreeBSD.org>

fgets(3) returns a pointer, so compare against NULL, not integer 0.


# b3608ae1 03-Jan-2012 Ed Schouten <ed@FreeBSD.org>

Replace index() and rindex() calls with strchr() and strrchr().

The index() and rindex() functions were marked LEGACY in the 2001
revision of POSIX and were subsequently removed from the 2008 revision.
The strchr() and strrchr() functions are part of the C standard.

This makes the source code a lot more consistent, as most of these C
files also call into other str*() routines. In fact, about a dozen
already perform strchr() calls.


# 7c9acc77 10-Jul-2011 Xin LI <delphij@FreeBSD.org>

peeraddr is only used in sizeof() evaluations, so instead of declaring it
a variable, use typedef.

MFC after: 1 month


# aa7e4bb4 24-Jun-2011 Kevin Lo <kevlo@FreeBSD.org>

Remove duplicated header files


# f4b7e64d 15-Jun-2011 Craig Rodrigues <rodrigc@FreeBSD.org>

Specify correct RFC2347 for TFTP options in diagnostic message.


# f471745a 31-May-2011 Warner Losh <imp@FreeBSD.org>

Fix a couple of spelling errors.

Submitted by: bcr@


# da52b4ca 11-Dec-2010 Joel Dahl <joel@FreeBSD.org>

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 04ebad38 24-Sep-2010 Marius Strobl <marius@FreeBSD.org>

Make WARNS=6 clean.

MFC after: 1 week


# 752fa694 04-May-2010 Warner Losh <imp@FreeBSD.org>

Go ahead and merge the work edwin@ on tftpd into the tree. It is a
lot better than what's in the tree now. Edwin tested it at a prior
employer, but can't test it today. I've found that it works a lot
better with the various uboot versions that I've used in my embedded
work. Here's the pkg-descr from the port that describes the changes:

It all started when we got some new routers, which told me the
following when trying to upload configuration or download images
from it: The TFTP server doesn't support the blocksize option.

My curiousity was triggered, it took me some reading of RFCs and
other documentation to find out what was possible and what could
be done. Was plain TFTP very simple in its handshake, TFTP with
options was kind of messy because of its backwards capability: The
first packet returned could either be an acknowledgement of options,
or the first data packet.

Going through the source code of src/libexec/tftpd and going through
the code of src/usr.bin/tftp showed that there was a lot of duplicate
code, and the addition of options would only increase the amount
of duplicate code. After all, both the client and the server can
act as a sender and receiver.

At the end, it ended up with a nearly complete rewrite of the tftp
client and server. It has been tested against the following TFTP
clients and servers:

- Itself (yay!)
- The standard FreeBSD tftp client and server
- The Fedora Core 6 tftp client and server
- Cisco router tftp client
- Extreme Networks tftp client

It supports the following RFCs:

RFC1350 - THE TFTP PROTOCOL (REVISION 2)
RFC2347 - TFTP Option Extension
RFC2348 - TFTP Blocksize Option
RFC2349 - TFTP Timeout Interval and Transfer Size Options
RFC3617 - Uniform Resource Identifier (URI) Scheme and Applicability
Statement for the Trivial File Transfer Protocol (TFTP)

It supports the following unofficial TFTP Options as described at
http://www.compuphase.com/tftp.htm:

blksize2 - Block size restricted to powers of 2, excluding protocol headers
rollover - Block counter roll-over (roll back to zero or to one)

From the tftp program point of view the following things are changed:

- New commands: "blocksize", "blocksize2", "rollover" and "options"
- Development features: "debug" and "packetdrop"

If you try this tftp/tftpd implementation, please let me know if
it works (or doesn't work) and against which implementaion so I can
get a list of confirmed working systems.

Author: Edwin Groothuis <edwin@FreeBSD.org>


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 1b0fa6fa 13-Oct-2008 Xin LI <delphij@FreeBSD.org>

ANSIfy, plus constify interfaces where possible.


# 3a4e1f47 13-Oct-2008 Xin LI <delphij@FreeBSD.org>

Use strlcpy() instead of strncpy() when we want the string to be
NUL-terminated.


# 2110d9c3 19-Oct-2005 Stefan Farfeleder <stefanf@FreeBSD.org>

Use the new name H_SETSIZE instead of the old H_EVENT to set the history
size.

PR: 86355


# 7f3a5689 11-Oct-2003 Tim J. Robbins <tjr@FreeBSD.org>

Fix BSS buffer overflow in makeargv().


# 891ca8cf 01-Oct-2003 Simon L. B. Nielsen <simon@FreeBSD.org>

tftp.1:
- Add the optional port argument to SYNOPSIS.
main.c:
- Sync usage with the manual page.

Approved by: trhodes (main.c part)
Obtained from: OpenBSD (jmc)
MFC after: 2 weeks


# 2e34a0f4 24-Mar-2003 Jonathan Chen <jon@FreeBSD.org>

fix reverse logic in "connect" command that cause port specifications to be ignored.

MFC after: 1 week


# 73f899ca 11-May-2002 Brian S. Dean <bsd@FreeBSD.org>

To perform even basic error checking, one must have an exit code that
indicates that not everything worked as expected. Exit non-zero if we
timed out while transmitting or receiving a file or if the file did
not exist, etc.

MFC After: 3 days (re@ willing)


# 8da9a6b0 13-Apr-2002 David Malone <dwmalone@FreeBSD.org>

Add some constness to make this WARNS clean again.


# 4dac6235 11-Apr-2002 Hajimu UMEMOTO <ume@FreeBSD.org>

IPv6 support for tftp/tftpd.

Obtained from: KAME
MFC after: 2 weeks


# 3f330d7d 21-Mar-2002 Warner Losh <imp@FreeBSD.org>

remove __P


# 8f4c8256 27-Feb-2002 David Malone <dwmalone@FreeBSD.org>

1) Move FreeBSD ID below vendor ID and don't compile vendor ID.
2) Cast some numbers we know to be positive to size_t before we MIN them
with the result of a sizeof.
3) Compare result of inet_addr to INADDR_NONE, not -1.


# b50764b0 04-Jan-2002 Guido van Rooij <guido@FreeBSD.org>

Argh...argv->argc


# 57aa7d50 04-Jan-2002 Guido van Rooij <guido@FreeBSD.org>

Fix the coredump that occurs when, from the tfpt prompt, a 'c' command is
issued without an argument.


# 8049f797 11-Dec-2001 Mark Murray <markm@FreeBSD.org>

WARNS=2 fixes. NO_WERROR set as there are some hard-to-fix
signed/unsigned comparisons. Use __FBSDID().


# 8979160a 18-Oct-2001 Bruce Evans <bde@FreeBSD.org>

Fixed most style bugs in previous commit.


# c33ed450 18-Oct-2001 Matthew N. Dodd <mdodd@FreeBSD.org>

Add libedit support to tftp.


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 8692ad46 30-Oct-1998 David Greenman <dg@FreeBSD.org>

Rename a function name so that it doesn't conflict with a future system call.


# a716ad66 08-Jun-1998 Warner Losh <imp@FreeBSD.org>

Don't assume that hp->h_lenght == 4. Be conservative in its use.
Submitted by: J. Assange a long time ago.


# fd129a02 14-Aug-1997 Philippe Charnier <charnier@FreeBSD.org>

Use err(3). 100 -> MAXHOSTNAMELEN from OpenBSD.
Obtained from: OpenBSD


# eaa86f9d 13-Sep-1996 Bruce Evans <bde@FreeBSD.org>

Don't use __dead or __pure in user code. They were obfuscations
for gcc >= 2.5 and no-ops for gcc >= 2.6. Converted to use __dead2
or __pure2 where it wasn't already done, except in math.h where use
of __pure was mostly wrong.


# ca22ff9e 27-Dec-1995 Joerg Wunsch <joerg@FreeBSD.org>

Kill the (hopefully) last occurance of gets(3) in the base source tree.


# 7799f52a 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources