Question

It is probably relevant to other questions too. I need to build a simple TFTP server in C (octet mode only) that will work with most TFTP clients available today (I only need to implement the server).

opcode   //2 byte
filename // string (unknown size)
0        // 1 byte
mode     // string (unknows size, max 9 chars considering 'netascii')
0        // 1 byte

But I'm having a problem: the RRQ/WRQ packets have a unknown length field "filename" (and "mode"). Because my server needs to be generic, how can I implement this option? Create a ridiculously large buffer and wait until recvfrom() returns 0?

Thanks!

Was it helpful?

Solution

make the buffer no much larger than the payload size of an Ethernet packet... with TFTP recvfrom won't return buffers larger than that...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top