This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
tftp server fix
- From: Øyvind Harboe <oyvind dot harboe at zylin dot com>
- To: ecos-patches at sources dot redhat dot com
- Date: Mon, 19 Apr 2004 15:10:55 +0200
- Subject: tftp server fix
- Organization: Zylin AS
--
Øyvind Harboe
http://www.zylin.com
Index: net/common/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/ChangeLog,v
retrieving revision 1.59
diff -u -r1.59 ChangeLog
--- net/common/current/ChangeLog 13 Apr 2004 14:36:27 -0000 1.59
+++ net/common/current/ChangeLog 19 Apr 2004 13:06:30 -0000
@@ -1,3 +1,10 @@
+2004-04-19 Oyvind Harboe <oyvind.harboe@zylin.com>
+
+ * 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-13 Sandeep Kumar <sandeep@codito.com>
* src/network_support.c (init_all_network_interfaces): Fix argument to
Index: net/common/current/src/tftp_server.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/src/tftp_server.c,v
retrieving revision 1.6
diff -u -r1.6 tftp_server.c
--- net/common/current/src/tftp_server.c 14 May 2003 07:02:06 -0000 1.6
+++ net/common/current/src/tftp_server.c 19 Apr 2004 13:06:35 -0000
@@ -59,6 +59,7 @@
#include <tftp_support.h> // TFTPD structures
#include <cyg/kernel/kapi.h>
#include <stdlib.h> // For malloc
+#include <fcntl.h>
#define nCYGOPT_NET_TFTP_SERVER_INSTRUMENT
#ifdef CYGOPT_NET_TFTP_SERVER_INSTRUMENT
@@ -264,7 +265,7 @@
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);