Browse Source

Check for correct block number in tftp_rx_data().

(Problem observed by Clay McClure in VMware Fusion.)
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
972f293e46
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      src/net/udp/tftp.c

+ 9
- 1
src/net/udp/tftp.c View File

415
 static int tftp_rx_data ( struct tftp_request *tftp,
415
 static int tftp_rx_data ( struct tftp_request *tftp,
416
 			  struct io_buffer *iobuf ) {
416
 			  struct io_buffer *iobuf ) {
417
 	struct tftp_data *data = iobuf->data;
417
 	struct tftp_data *data = iobuf->data;
418
-	unsigned int block;
418
+	int block;
419
 	size_t data_len;
419
 	size_t data_len;
420
 	int rc;
420
 	int rc;
421
 
421
 
432
 	iob_pull ( iobuf, sizeof ( *data ) );
432
 	iob_pull ( iobuf, sizeof ( *data ) );
433
 	data_len = iob_len ( iobuf );
433
 	data_len = iob_len ( iobuf );
434
 
434
 
435
+	/* Check for correct block */
436
+	if ( block != ( tftp->state + 1 ) ) {
437
+		DBGC ( tftp, "TFTP %p received out-of-order block %d "
438
+		       "(expecting %d)\n", tftp, block, ( tftp->state + 1 ) );
439
+		free_iob ( iobuf );
440
+		return 0;
441
+	}
442
+
435
 	/* Deliver data */
443
 	/* Deliver data */
436
 	if ( ( rc = xfer_deliver_iob ( &tftp->xfer, iobuf ) ) != 0 ) {
444
 	if ( ( rc = xfer_deliver_iob ( &tftp->xfer, iobuf ) ) != 0 ) {
437
 		DBGC ( tftp, "TFTP %p could not deliver data: %s\n",
445
 		DBGC ( tftp, "TFTP %p could not deliver data: %s\n",

Loading…
Cancel
Save