mirror of
https://github.com/xcat2/xNBA.git
synced 2024-11-26 11:19:17 +00:00
[tftp] Allow fetching larger files by wrapping block number
This patch adds TFTP support for files larger than 65535 blocks by wrapping the 16-bit block number. Reported-by: Mark Johnson <johnson.nh@gmail.com> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com> Signed-off-by: Marty Connor <mdc@etherboot.org>
This commit is contained in:
parent
734061e9c6
commit
dd99ee95cb
@ -747,7 +747,7 @@ static int tftp_rx_data ( struct tftp_request *tftp,
|
||||
struct io_buffer *iobuf ) {
|
||||
struct tftp_data *data = iobuf->data;
|
||||
struct xfer_metadata meta;
|
||||
int block;
|
||||
unsigned int block;
|
||||
off_t offset;
|
||||
size_t data_len;
|
||||
int rc;
|
||||
@ -759,14 +759,17 @@ static int tftp_rx_data ( struct tftp_request *tftp,
|
||||
rc = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
if ( data->block == 0 ) {
|
||||
|
||||
/* Calculate block number */
|
||||
block = ( ( bitmap_first_gap ( &tftp->bitmap ) + 1 ) & ~0xffff );
|
||||
if ( data->block == 0 && block == 0 ) {
|
||||
DBGC ( tftp, "TFTP %p received data block 0\n", tftp );
|
||||
rc = -EINVAL;
|
||||
goto done;
|
||||
}
|
||||
block += ( ntohs ( data->block ) - 1 );
|
||||
|
||||
/* Extract data */
|
||||
block = ( ntohs ( data->block ) - 1 );
|
||||
offset = ( block * tftp->blksize );
|
||||
iob_pull ( iobuf, sizeof ( *data ) );
|
||||
data_len = iob_len ( iobuf );
|
||||
|
Loading…
Reference in New Issue
Block a user