Date: Thu, 23 Jan 1997 07:04:41 -0800 (PST) From: staylor@cancercare.net To: freebsd-gnats-submit@freebsd.org Subject: bin/2566: tftpd.c does not truncate a file upon open (write) Message-ID: <199701231504.HAA22802@freefall.freebsd.org> Resent-Message-ID: <199701231510.HAA23013@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 2566 >Category: bin >Synopsis: tftpd.c does not truncate a file upon open (write) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 23 07:10:01 PST 1997 >Last-Modified: >Originator: Steve Taylor >Organization: Cancer Care Network, Inc. >Release: 2.1.5 >Environment: FreeBSD cancer.cancercare.net 2.1.5-STABLE FreeBSD 2.1.5-STABLE #0: Wed Oct 16 0 2:06:19 CDT 1996 root@cancer.cancercare.net:/usr/src/sys/compile/CANCER i38 6 >Description: When TFTP-ing a file to the FreeBSD server, if a file already exists, it is not truncated. So, if the file that you are sending is shorter than the file that's there already, the "new" file that you are sending will end-up with some of the old file at the "new" file's end. >How-To-Repeat: Send a 50KB file via tftp. Then, send a 20KB file. Now, look at the tftp-ed file on the FreeBSD machine - it's 50KB. It contains 20KB of the second file, followed by 30KB of the original (50KB) file. >Fix: change the following line in the /usr/src/libexec/tftpd/tftpd.c file: fd = open(filename, mode == RRQ ? 0 : 1) to fd = open(filename, mode == RRQ ? 0 : 1 | O_TRUNC) And, while you are at it, you may want to consider using O_RDONLY and O_WRONLY instead of 0 and 1. >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199701231504.HAA22802>