summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2008-07-03 00:01:25 +0200
committerMichael Brown2008-07-03 00:01:25 +0200
commit227bb05a50f1f15073bd051f2bb5b6d3f7270f2b (patch)
tree7338f893ecc2ea72895fe18e9ccfc5b577875aaf
parent[i386] Change semantics of __from_data16 and __from_text16 (diff)
downloadipxe-227bb05a50f1f15073bd051f2bb5b6d3f7270f2b.tar.gz
ipxe-227bb05a50f1f15073bd051f2bb5b6d3f7270f2b.tar.xz
ipxe-227bb05a50f1f15073bd051f2bb5b6d3f7270f2b.zip
[tftp] Strip the initial '/' to keep Windows TFTP servers happy.
-rw-r--r--src/net/udp/tftp.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/net/udp/tftp.c b/src/net/udp/tftp.c
index e49bcf9f..8fdb3714 100644
--- a/src/net/udp/tftp.c
+++ b/src/net/udp/tftp.c
@@ -316,17 +316,30 @@ void tftp_set_mtftp_port ( unsigned int port ) {
*/
static int tftp_send_rrq ( struct tftp_request *tftp ) {
struct tftp_rrq *rrq;
- const char *path = tftp->uri->path;
- size_t len = ( sizeof ( *rrq ) + strlen ( path ) + 1 /* NUL */
- + 5 + 1 /* "octet" + NUL */
- + 7 + 1 + 5 + 1 /* "blksize" + NUL + ddddd + NUL */
- + 5 + 1 + 1 + 1 /* "tsize" + NUL + "0" + NUL */
- + 9 + 1 + 1 /* "multicast" + NUL + NUL */ );
+ const char *path;
+ size_t len;
struct io_buffer *iobuf;
+ /* Strip initial '/' if present. If we were opened via the
+ * URI interface, then there will be an initial '/', since a
+ * full tftp:// URI provides no way to specify a non-absolute
+ * path. However, many TFTP servers (particularly Windows
+ * TFTP servers) complain about having an initial '/', and it
+ * violates user expectations to have a '/' silently added to
+ * the DHCP-specified filename.
+ */
+ path = tftp->uri->path;
+ if ( *path == '/' )
+ path++;
+
DBGC ( tftp, "TFTP %p requesting \"%s\"\n", tftp, path );
/* Allocate buffer */
+ len = ( sizeof ( *rrq ) + strlen ( path ) + 1 /* NUL */
+ + 5 + 1 /* "octet" + NUL */
+ + 7 + 1 + 5 + 1 /* "blksize" + NUL + ddddd + NUL */
+ + 5 + 1 + 1 + 1 /* "tsize" + NUL + "0" + NUL */
+ + 9 + 1 + 1 /* "multicast" + NUL + NUL */ );
iobuf = xfer_alloc_iob ( &tftp->socket, len );
if ( ! iobuf )
return -ENOMEM;