You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Rory Winston (JIRA)" <ji...@apache.org> on 2008/02/18 01:18:34 UTC

[jira] Commented: (NET-181) tftp client limited to ~32 MB file sizes

    [ https://issues.apache.org/jira/browse/NET-181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12569767#action_12569767 ] 

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 altered?

/***
     * 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;
        else
            _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: https://issues.apache.org/jira/browse/NET-181
>             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:
> http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol
> 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.