commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rory Winston (JIRA)" <>
Subject [jira] Commented: (NET-181) tftp client limited to ~32 MB file sizes
Date Mon, 18 Feb 2008 00:18:34 GMT


Rory Winston commented on NET-181:

Have you got a patch for this? I assume it may just be the following code that needs to be

     * Creates a data packet to be sent to a host at a given port
     * with a given block number.  The actual data to be sent is passed as
     * an array, an offset, and a length.  The offset is the offset into
     * the byte array where the data starts.  The length is the length of
     * the data.  If the length is greater than MAX_DATA_LENGTH, it is
     * truncated.
     * <p>
     * @param destination  The host to which the packet is going to be sent.
     * @param port  The port to which the packet is going to be sent.
     * @param blockNumber The block number of the data.
     * @param data The byte array containing the data.
     * @param offset The offset into the array where the data starts.
     * @param length The length of the data.
    public TFTPDataPacket(InetAddress destination, int port, int blockNumber,
                          byte[] data, int offset, int length)
        super(TFTPPacket.DATA, destination, port);

        _blockNumber = blockNumber;
        _data = data;
        _offset = offset;

        if (length > MAX_DATA_LENGTH)
            _length = MAX_DATA_LENGTH;
            _length = length;

    public TFTPDataPacket(InetAddress destination, int port, int blockNumber,
                          byte[] data)
        this(destination, port, blockNumber, data, 0, data.length);

     * Creates a data packet based from a received
     * datagram.  Assumes the datagram is at least length 4, else an
     * ArrayIndexOutOfBoundsException may be thrown.
     * <p>
     * @param datagram  The datagram containing the received data.
     * @throws TFTPPacketException  If the datagram isn't a valid TFTP
     *         data packet.
    TFTPDataPacket(DatagramPacket datagram) throws TFTPPacketException
        super(TFTPPacket.DATA, datagram.getAddress(), datagram.getPort());

        _data = datagram.getData();
        _offset = 4;

        if (getType() != _data[1])
            throw new TFTPPacketException("TFTP operator code does not match type.");

        _blockNumber = (((_data[2] & 0xff) << 8) | (_data[3] & 0xff));

        _length = datagram.getLength() - 4;

        if (_length > MAX_DATA_LENGTH)
            _length = MAX_DATA_LENGTH;

> tftp client limited to ~32 MB file sizes
> ----------------------------------------
>                 Key: NET-181
>                 URL:
>             Project: Commons Net
>          Issue Type: Improvement
>         Environment: All
>            Reporter: Dan Armbrust
>            Priority: Minor
> I just noticed that the TFTPClient class does not support a block wraparound - hence,
when the block number exceeds the max allowed by the rfc (65535) - about a 32 mb file - bad
things will happen.
> I can't find any rfc that specifies how the wraparound is supposed to occur, but this
wiki page mentions it:
> And I am working on implementing a TFTPServer - and in my tests with the tftp client
that is shipped with fedora, I have determined that that tftp client expects the next block
number after 65535 to be 0.
> So it appears that the TFTPClient should wrap its block number so that it properly supports
larger files.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message