# HG changeset patch # User jlarmour # Date 1083223197 0 # Node ID 26840b4642385fe7f1b280a582ed3f1d94ba0c6b # Parent d04fae1f5cdef548a7d3d5bf93029c46c30fe62f * src/tftp_server.c: files are now created with the O_CREAT|O_TRUNC|O_WRONLY so it is possible to write to non-existing files and that overwriting a larger file with a smaller file does not leave a garbage at the end. diff --git a/packages/net/common/current/ChangeLog b/packages/net/common/current/ChangeLog --- a/packages/net/common/current/ChangeLog +++ b/packages/net/common/current/ChangeLog @@ -1,3 +1,10 @@ +2004-04-19 Oyvind Harboe + + * src/tftp_server.c: files are now created with the + O_CREAT|O_TRUNC|O_WRONLY so it is possible to write to + non-existing files and that overwriting a larger file with + a smaller file does not leave a garbage at the end. + 2004-04-19 John Dallaway * doc/tcpip.sgml: Remove reference to RedBoot documentation diff --git a/packages/net/common/current/src/tftp_server.c b/packages/net/common/current/src/tftp_server.c --- a/packages/net/common/current/src/tftp_server.c +++ b/packages/net/common/current/src/tftp_server.c @@ -59,6 +59,7 @@ #include // TFTPD structures #include #include // For malloc +#include #define nCYGOPT_NET_TFTP_SERVER_INSTRUMENT #ifdef CYGOPT_NET_TFTP_SERVER_INSTRUMENT @@ -264,7 +265,7 @@ tftpd_write_file(struct tftp_server *ser freeaddrinfo(res); return; } - if ((fd = (server->ops->open)(hdr->th_stuff, O_WRONLY)) < 0) { + if ((fd = (server->ops->open)(hdr->th_stuff, O_WRONLY|O_TRUNC|O_CREAT)) < 0) { tftpd_send_error(s,reply,TFTP_ENOTFOUND,from_addr, from_len); close(s); freeaddrinfo(res);