mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-28 06:52:45 +00:00
Truncate the file when opening it with write intent. Otherwise,
there's a good chance that garbage will remain at the end. Closes PR # bin/2112: tftpd doesn't truncate ... Reviewed by: fenner
This commit is contained in:
parent
0c6ed4736c
commit
84e1b7d26b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20052
@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: tftpd.c,v 1.4 1996/09/22 21:56:07 wosch Exp $
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
@ -435,7 +435,7 @@ validate_access(filep, mode)
|
||||
return (err);
|
||||
*filep = filename = pathname;
|
||||
}
|
||||
fd = open(filename, mode == RRQ ? 0 : 1);
|
||||
fd = open(filename, mode == RRQ ? O_RDONLY : O_WRONLY|O_TRUNC);
|
||||
if (fd < 0)
|
||||
return (errno + 100);
|
||||
file = fdopen(fd, (mode == RRQ)? "r":"w");
|
||||
|
Loading…
Reference in New Issue
Block a user