|
@@ -747,7 +747,7 @@ static int tftp_rx_data ( struct tftp_request *tftp,
|
747
|
747
|
struct io_buffer *iobuf ) {
|
748
|
748
|
struct tftp_data *data = iobuf->data;
|
749
|
749
|
struct xfer_metadata meta;
|
750
|
|
- int block;
|
|
750
|
+ unsigned int block;
|
751
|
751
|
off_t offset;
|
752
|
752
|
size_t data_len;
|
753
|
753
|
int rc;
|
|
@@ -759,14 +759,17 @@ static int tftp_rx_data ( struct tftp_request *tftp,
|
759
|
759
|
rc = -EINVAL;
|
760
|
760
|
goto done;
|
761
|
761
|
}
|
762
|
|
- if ( data->block == 0 ) {
|
|
762
|
+
|
|
763
|
+ /* Calculate block number */
|
|
764
|
+ block = ( ( bitmap_first_gap ( &tftp->bitmap ) + 1 ) & ~0xffff );
|
|
765
|
+ if ( data->block == 0 && block == 0 ) {
|
763
|
766
|
DBGC ( tftp, "TFTP %p received data block 0\n", tftp );
|
764
|
767
|
rc = -EINVAL;
|
765
|
768
|
goto done;
|
766
|
769
|
}
|
|
770
|
+ block += ( ntohs ( data->block ) - 1 );
|
767
|
771
|
|
768
|
772
|
/* Extract data */
|
769
|
|
- block = ( ntohs ( data->block ) - 1 );
|
770
|
773
|
offset = ( block * tftp->blksize );
|
771
|
774
|
iob_pull ( iobuf, sizeof ( *data ) );
|
772
|
775
|
data_len = iob_len ( iobuf );
|